-
Notifications
You must be signed in to change notification settings - Fork 1
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
PureComponents, by default #34
Conversation
This update adjusts the create-emotion-styled HOC to create React.PureComponent styled components, by default. This is for an overall performance boost, as PureComponent classes perform faster than default Component classes. This should be safe, as we've been using PureComponents exclusively, at the library level, for a while now. Not to mention, React Redux also defaults to PureComponents. This behaviour can be customized by defining `{ pure: false }` in a new argument for `create-emotion-styled`.
@@ -1,7 +1,6 @@ | |||
{ | |||
"recommendations": [ | |||
"dbaeumer.vscode-eslint", | |||
"flowtype.flow-for-vscode", |
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.
Going to (eventually) replace Flow with TS.
This will probably happen during the Emotion 9 -> 10 migration
@@ -85,7 +96,9 @@ function createEmotionStyled(emotion: Object, view: ReactType) { | |||
} | |||
} | |||
|
|||
class Styled extends view.Component<*, {theme: Object}> { | |||
const OuterBaseComponent = pure ? view.PureComponent : view.Component |
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.
Pattern established in wedux
(inspired by react-redux
)
PureComponents, by default
This update adjusts the create-emotion-styled HOC to create
React.PureComponent styled components, by default. This is for an
overall performance boost, as PureComponent classes perform faster
than default Component classes.
This should be safe, as we've been using PureComponents exclusively,
at the library level, for a while now. Not to mention, React Redux
also defaults to PureComponents.
This behaviour can be customized by defining
{ pure: false }
in anew argument for
create-emotion-styled
.