DEV Community

Discussion on: State update issue

Collapse
 
arunavamodak profile image
Arunava Modak

Instead of trying to log it right after setState, you can try to write a useEffect, which watches for changes in state and print it there.

The problem here is, your state value is getting logged before the update in completed in your state.