Skip to content
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

Merged
merged 1 commit into from
Dec 3, 2018
Merged

PureComponents, by default #34

merged 1 commit into from
Dec 3, 2018

Conversation

ItsJonQ
Copy link
Contributor

@ItsJonQ ItsJonQ commented Dec 3, 2018

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 a
new argument for create-emotion-styled.

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`.
@ItsJonQ ItsJonQ added the enhancement New feature or request label Dec 3, 2018
@ItsJonQ ItsJonQ self-assigned this Dec 3, 2018
@@ -1,7 +1,6 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"flowtype.flow-for-vscode",
Copy link
Contributor Author

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
Copy link
Contributor Author

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)

@coveralls
Copy link

Pull Request Test Coverage Report for Build 205

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 204: 0.0%
Covered Lines: 77
Relevant Lines: 77

💛 - Coveralls

@ItsJonQ ItsJonQ merged commit 952152b into master Dec 3, 2018
@ItsJonQ ItsJonQ deleted the pure-by-default branch January 8, 2019 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants