-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(www): migrate to emotion 10 #11771
Conversation
Marking this a WIP - I tested it for all of 5 minutes 🤷♂️ Will revisit this later today. |
As discussed previously here: The code below will break: www/src/components/navigation-mobile.js
In my project, i just used the activeStyle prop in the Link component below:
|
Couldn't we do something like this
|
@t2ca no - unfortunately. We use custom syntax (e.g. I'm thinking of just adding an attribute that we can style against. See 7c6a0cc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no breaking things, just adding a few comments. I'll approve anyway
@@ -178,7 +178,7 @@ class Form extends React.Component { | |||
type="email" | |||
required | |||
autoComplete="email" | |||
innerRef={input => { | |||
ref={input => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we move to createRef?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the benefit? Shouldn't these work exactly the same?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no benefit just following best practices
The examples below have been updated to use the React.createRef() API introduced in React 16.3. If you are using an earlier release of React, we recommend using callback refs instead.
https://reactjs.org/docs/refs-and-the-dom.html
it was more like oh he changes innerRef to ref, maybe update using createRef too but no biggy 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! I've always thought that createRef was providing an alternate/better mechanism to string refs, e.g. ref="someValue"
. I didn't know if it's preferred over callback refs, but rather just seems to be an alternate API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment there is no real benefit for it but I can imagine that they will deprecate old behaviour in the next release as with createRef
the framework has a bit more control
}), | ||
} | ||
const getProps = ({ isPartiallyCurrent }) => | ||
isPartiallyCurrent && { "data-active": true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not a fan of this syntax though 😋 (just preference)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would you change it? (I don't like it that much either!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const getProps = ({ isPartiallyCurrent }) => {
if (!isPartiallyCurrent ) {
return
}
return { "data-active": true }
}
it's more code but the minifier takes care of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wardpeet Why start with the falsy value in your if rather than the opposite? It saves 1 character by removing the !
.
const getProps = ({ isPartiallyCurrent }) => {
if (isPartiallyCurrent) {
return { "data-active": true }
}
return
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just the code style I use. It's called Return Early
. I like to put meaningless returns like error state or null returns at the top and actual code that I should care about in the happy path at the bottom.
Let's not go into the world of micro-benchmarking it's most of the time not worth it. In this example, there will be nothing to win as a minifier just fixes this.
your snippet:
const getProps = ({ isPartiallyCurrent }) => {
if (isPartiallyCurrent) {
return { "data-active": true }
}
return
}
minification:
const getProps=({isPartiallyCurrent:t})=>{if(t)return{"data-active":!0}};
my snippet:
const getProps = ({ isPartiallyCurrent }) => {
if (!isPartiallyCurrent ) {
return
}
return { "data-active": true }
}
minification:
const getProps=({isPartiallyCurrent:t})=>{if(t)return{"data-active":!0}};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wardpeet No no, don't worry, I was simply asking out of curiosity. Thanks for the clarification. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no breaking things, just adding a few comments. I'll approve anyway
bde2413
to
08877e5
Compare
<3 🙏 |
Description
Migrate www/ to emotion 10