DEV Community

Discussion on: New Redux Hooks: A Before And After Comparison. Are They Better?

Collapse
 
adred8 profile image
Vaibhav

I am using useSelector to get a reducer data and then trying to store it in a local state using useState hook which appears is not happening synchronously.

The reducer data gets printed in console but the variable set using useState prints empty string instead

I am not sure why this is happening but I had to update the state in the useEffect conditionally instead because of this to store reducer data in the local state using useState hook