Always loading initialState
See original GitHub issueGreat package! When I tried this, it seems that it always loads the initial state for me. My code looks like this:
import { AsyncStorage } from 'react-native'
import { applyMiddleware, createStore, compose } from 'redux'
import { persistStore, autoRehydrate } from 'redux-persist'
import createLogger from 'redux-logger'
import reducersCombined from './reducers/combined'
import initialState from './initialState'
const middlewares = [
createLogger()
]
const enhancers = [
applyMiddleware(...middlewares),
autoRehydrate()
]
const store = createStore(reducersCombined, initialState, compose(...enhancers))
persistStore(store, { storage: AsyncStorage })
export default store
What am I doing wrong here? Could be that I misunderstood something as I’m quite new to redux.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:26
- Comments:53 (4 by maintainers)
Top Results From Across the Web
default state of loading in reducer always true? - Stack Overflow
Above problem is that SomethingElse component will still got rendered once which is not what I want. So what's your initialState of loading?...
Read more >Initializing State | Redux
In general, preloadedState wins over the state specified by the reducer. This lets reducers specify initial data that makes sense to them as ......
Read more >HOW TO PROPERLY SET INITIAL STATE IN REDUX
There is only one way to change its state and that is by dispatching actions. Actions are objects that consist of a type...
Read more >Why do I receive an error loading initial state when building a ...
Why do I receive an error loading initial state. ... Error loading the initial state for model 'Subsystem'. ... More often than not....
Read more >State persistence | React Navigation
initialState - This prop allows us to pass an initial state to use for navigation ... an empty/loading view for a moment before...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Shoot.
persistStore
happens after return? Good idea, self.@leguma Thanks, yep the problem was in my reducer. My mistake was in “default: return { … state }” not “return state”