loading...

re: πŸ”₯ Learn React in 10 Tweets (with hooks) VIEW POST

TOP OF THREAD FULL DISCUSSION
re: That's important if you're doing multiple setCount calls or async ones, yes absolutely. With just the one, it's fine to use the previous value. B...
 

Hey Chris in order to keep your teachings high quality I would strongly suggest for you to change the number 7.
Clicking thrice fast enough in the button can already cause an inconsistency between clicks and count value.
I have to remember people all the time that setState is an async action, and we often find flaky tests because of patterns like the one you're using, so, please, for the sake of newcomers doing the right thing. Change it to use the callback syntax.

I'll have to test that, yeah - I often forget about the callback syntax myself :/ so it would be good for me to remember too! Thanks for the tip

code of conduct - report abuse