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

Use the updater form of setState #2

Open
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
3 participants
@gaearon
Copy link
Contributor

gaearon commented Mar 3, 2019

Before:

screen shot 2019-03-03 at 12 26 20 am

(due to artifical overhead in the memo components)

After:

screen shot 2019-03-03 at 12 27 26 am

This is roughly the same as the class version (the variance in both is >10%):

screen shot 2019-03-03 at 12 31 32 am


Alternatively, #3 is the preferred solution for more complex cases.

@gaearon

This comment has been minimized.

Copy link
Contributor Author

gaearon commented Mar 3, 2019

Note that the Hooks version appears faster for initial mount for me:

screen shot 2019-03-03 at 12 30 51 am

Compared to a class:

screen shot 2019-03-03 at 12 26 20 am

Not sure if you can replicate this.

@ryardley

This comment has been minimized.

Copy link
Owner

ryardley commented Mar 3, 2019

Cool I will have a go at replicating it and attempt to put together an article on it but it means I need to restructure this repo a little so I might hold off on merging this.

@mstaicu

This comment has been minimized.

Copy link

mstaicu commented Mar 19, 2019

Could I follow up with a question @gaearon ? I would be very interested in how you calculated the variance. Do you think it would be off-topic if you could explain it in this thread?

@gaearon

This comment has been minimized.

Copy link
Contributor Author

gaearon commented Mar 19, 2019

Oh I mean I just looked at ~10 results and looked how much they fluctuate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.