Accessing state immediately after setState() before it updates
A common React pitfall is trying to access an updated state value immediately after calling setState or the state setter from useState. This doesn’t work because state updates are asynchronous….