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
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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