How to get the PREVIOUS state in React?
Let's start by asking ourselves why would we need the previous state? There might be some cases where you need to render a different view which also changes the current state based on the previous state.
Consider a simple example - you have an ON/OF...
karanhejmadi.hashnode.dev3 min read
paddingleft
How about - setCount(prevCount => prevCount + 1)}