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.
function MyComponent(props) {
return (
<div>{props.children}</div>
)
}
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
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: