Redux State Mutates unexpectedly
- [x] Issue does not already exist /* As far as I can tell */
- Identify exactly what aspect your issue is about
- [x] ignite base application
ignite doctor:
Computer
Platform: darwin
Ignite
Version: 1.5.0
Path: /usr/local/bin/ignite
Node
Version: v5.4.0
Path: /Users/christopherbradley/.nvm/versions/node/v5.4.0/bin/node
NPM
Version: 3.10.6
Path: /usr/local/bin/npm
Yeoman
Version: 1.8.4
React Native CLI
Version: 1.0.0
App
React Native Version: 0.31.0
Something seems to be destroying redux state. I've created a test example demonstrating the issue here: https://github.com/chrbradley/ingiteTestState/tree/add-new-state
In my example I modify the state in the StartUp saga and then MapStateToProps in the TestState component.
You can see that the state is present when the component initially renders, but something modifies the state which triggers a rerender of TestState component.
When the TestState component rerenders, the state is no longer there. Did I miss something when I created the new state object?
Can you turn off the redux persist option and try again? I wonder if that is causing grief. We had some issues with that recently.
@chrbradley I would suggest you add your slices of state that you're still developing to the "Blacklist" (line 14 of your index.js (RootReducer) file) This will allow you to modify the state, and store updated values only per your Actions, and not from some previously built slice of state that ReduxPersist is remembering when it compiles as middleware in the createStore( ) function. The blacklist is seen by ReduxPersist and does not "persist" previous instances of state that it finds inside of that array.
@skellock You're correct, turning off redux persist fixed the issue. Based on this, I'd speculate that the rehydration is happening too late (after the startup saga fires).
Also when I've used redux persist in the past, I typically see a log event after it dispatches. The logger isn't picking up the rehydration.
Digging into this now.
There's a few issues outstanding with redux persist. Someone suggested moving up to v3 might be the solution? I'll look as well today. Thx dude!

This is that timing issue. STARTUP is firing before REHYDRATE. 💩
What about a simple check.
If rehydrate is on, then call startup on rehydrate
if it's off, call startup right away.
Firiing the startup action like GantMan said is the solution at the moment and it works for me..
@lukabers - would love a PR with that change! Mind sharing?
I'll share on monday! Let me test a bit
fixed by @lukabers in #379 - will be in next version's release.