Not so long ago I started working with functional components instead of class based ones. The main goal was to learn how to implement React Hooks i...
For further actions, you may consider blocking this person and/or reporting abuse
Every time the next state is based on the existing one, better use the callback version of the state updater. Here it would be
updateCarSpeed(prevCarSpeed => prevCarSpeed + 5).I will be glad to use the callback version. Thank you for the advice. Do you mind explaining in more detail, why exactly is it better to use the callback version?
I think it's similar to setState in the class components - you can be sure that you're updating the correct value, am I right @guico33 ?
Yes
If you're interested to see more functional components with TypeScript, check out our recent github.com/UnlyEd/next-right-now OSS release. We also prefer functional components over classes, and thus hooks over HOC.
Great cheat sheet!
Also there is a typo in the second object example.
I guess you wanted to call updateForm instead of updateField in the updateField function
Oh thank you!
Nice observation, I indeed did wanted to call updateForm. Fix coming right up :)
Nice article Juraj :)
Have my gratitude :)