Open sabun123 opened 4 years ago
@sabun123 I thought I was seeing the same behavior. But what is actually happening for me is that sagas are running before rehydrate is dispatched. So I just need to gate the sagas in a similar fashion, take('persist/rehydrate')
. Are you sure you aren't running into something similar, since I see you are using sagaMiddleware as well?
@sabun123 Any updates?
I too am having he same issue.
I see in the debugger that these actions are happening on app load
1) @@init happens - my loading component is shown
2) persist/PERSIST - happens and the gate appears to lift because my component inside persystGate is rendered! Should not be correct?
3) persist/REHYDRATE - comes next and my state is loaded and onBeforeLift is called
4) more actions...
Why is persist/PERSIST being called at all when we are loading from storage? Why is the gate being released before rehydrate?
Hi there,
Issue: PersistGate gets permission to render before persist/REHYDRATE is actually complete. Both the _persist.rehydrated and bootstrapped values are true even before the persistStore callback function is fired. This is on the web, using React 16.7.
Versions I've tried:
version 5.10.0
version 6.0.0
Details: What happens is that PersistGate gets it's bootstrapped value set to true, but the persistStore callback function that helps determine when the rehydration process is complete is only ran after this. This basically means that on browser refresh, the app renders before my authorization tokens get set so any API calls fail.
What could I be doing wrong?
Code:
App.js
store.js
Logging it out:
Notice that the rehydration completes AFTER persistGate has already allowed the app to render. My understanding is that PersistGate is supposed to prevent rendering until after rehydration is complete. (token not logged out for privacy reasons here).