Usage with createStore preloadedState parameter?
See original GitHub issueHi, I have the following code in my app.js
reducer:
const defaultState = {
count: 1,
type: null,
}
...
export default handleActions(reducerMap, defaultState)
And I am trying to preload the type
state when creating the store:
const preloadedState = {
app: {
type: "apple",
},
}
const store = createStore(reducers, preloadedState, applyMiddleware(thunkMiddleware))
But I got the error that count
state became undefined
,
Seems by using redux-actions
I was unable to check and assign state into defaultState
Issue Analytics
- State:
- Created 7 years ago
- Comments:7
Top Results From Across the Web
createStore | Redux
createStore (reducer, [preloadedState], [enhancer]). Creates a Redux store that holds the complete state tree of your app.
Read more >Unexpected key found in preloadedState argument passed to ...
TLDR: stop using combineReducers and pass your reducer to createStore directly. Use import reducer from './foo' instead of import * from './foo' ....
Read more >createStore · Redux
Arguments · reducer (Function): A reducing function that returns the next state tree, given the current state tree and an action to handle....
Read more >Second argument to createStore in redux - JavaScript
What i don't understand is the explanation of the second argument preloadedState . [ preloadedState ] (any) : The initial state. You may ......
Read more >Initializing State - reducers - Redux Documents
The createStore method can accept an optional preloadedState value as its ... argument that is undefined , and returning the value they'd like...
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 FreeTop 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
Top GitHub Comments
@yangmillstheory I see, thanks for helping!