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

[performance] Cache by the resulting WithStyles HOC #234

Merged
merged 4 commits into from
Oct 21, 2019

Conversation

noratarano
Copy link
Collaborator

@noratarano noratarano commented Oct 18, 2019

Summary

  1. Cache even further by the resulting WithStyles component so that we avoid calling create/resolve unnecessarily per component instance. Before, we were calling create once per theme, per component instance, per direction. This way, we're calling create once per theme, per component definition, per direction, which should happen less often.

  2. We also refactor some class methods that didn't need to be class methods

I would especially appreciate feedback around the organization of this code for performance and clarity. Take a look at the commits for easy of review.

Reviewers

@esprehn @TaeKimJR @joeuy @indiesquidge @ljharb @marsjosephine

Nora Tarano added 2 commits October 17, 2019 18:17
Cache by WithStyles component so that we avoid unnecessarily calling the
create function of aphrodite.
src/withStyles.jsx Outdated Show resolved Hide resolved
src/withStyles.jsx Outdated Show resolved Hide resolved
src/withStyles.jsx Outdated Show resolved Hide resolved
src/withStyles.jsx Outdated Show resolved Hide resolved
src/withStyles.jsx Outdated Show resolved Hide resolved
src/withStyles.jsx Show resolved Hide resolved
@noratarano
Copy link
Collaborator Author

@ljharb @esprehn Addressed comments. PTAL

Copy link

@esprehn esprehn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing!

getCurrentInterface() {
// Fallback to the singleton implementation
return (this.context && this.context.stylesInterface) || _getInterface();
return (
(this.context && this.context.stylesInterface) || _getInterface()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nbd ofc but this change seems surprising. is your editor running more than eslint autofix on things?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ljharb You're right this is weird, lol. I have some weird linting/prettier/editor autofix stuff going on 🤦‍♀ I tried fixing it but it's still giving me things like this.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally the only formatting you want enabled is eslint autofix - ie, in vscode, disable "format on save", and prettier, and be sure you don't have any global eslint installed (so it always uses the local one)

@noratarano noratarano merged commit e7ed4a2 into master Oct 21, 2019
@noratarano noratarano deleted the nora--memoize-more branch October 21, 2019 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants