You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had a question regarding the next-redux-wrapper library.
Scenario)
I hard refresh /login page. On this page I have getInitialProps setting username to user1. On that same page inside of a useEffect hook I also set a store property, first_name to jon. The hook gets called but immediately gets overwritten back to its initial state - but we keep the username that was set from getInitialProps.
Scenario 2)
I hard refresh /login page. On this page I have getInitialProps setting username to user1. On that same page inside of a useEffect hook I also set the same store property to user2. If I navigate to another page it persists as user2 in the store. That is until i navigate back to the /login page (without hard refreshing) that is sets it to user1.
I guess my question is - how exactly is it determining the order of events?
-edit
After some more digging I found that setting something similar to this:
is what fixes that side effect of having an inconsistent state during client side routing / hard refreshing. So when exactly is it necessary to do this bit of logic? For every bit of the store statee?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I had a question regarding the next-redux-wrapper library.
Scenario)
I hard refresh
/login
page. On this page I have getInitialProps settingusername
touser1
. On that same page inside of a useEffect hook I also set a store property,first_name
tojon
. The hook gets called but immediately gets overwritten back to its initial state - but we keep the username that was set from getInitialProps.Scenario 2)
I hard refresh
/login
page. On this page I have getInitialProps settingusername
touser1
. On that same page inside of a useEffect hook I also set the same store property touser2
. If I navigate to another page it persists asuser2
in the store. That is until i navigate back to the/login
page (without hard refreshing) that is sets it touser1
.I guess my question is - how exactly is it determining the order of events?
-edit

After some more digging I found that setting something similar to this:
is what fixes that side effect of having an inconsistent state during client side routing / hard refreshing. So when exactly is it necessary to do this bit of logic? For every bit of the store statee?
Beta Was this translation helpful? Give feedback.
All reactions