Hello,
I'm now learning React.js library and yesterday I read about prevState updater mechanism for class component but I cant find nothing about similar mechanism for functional component. Exist something similar or maybe it doesent needed?
Thank you
K.
Top comments (1)
Pre hooks, functional components didn't have a state. You can only pass props to the component and it will return an element. So, it's not needed to handle prevState in functional components.
However using hooks, prevState is the current value of the state (using useState).
For instance, using prevState in a Class component to reset the count when we reach 10
Using hooks: