I had set InitialState in my redux createStore method ,and I corresponding InitialState as second arguments
I got a error in browser:
Un
The initialState
argument in createStore()
is often tripping people. It was never meant as a way to “initialize” your application state manually. The only useful applications for it are:
It is implied that you never write initialState
manually and in most apps you don’t even use it. Instead, reducers must always specify their own initial state, and initialState
is just a way to prefill that state when you have an existing serialized version of it.
So this answer is correct: you need to define the initial state in your reducer. Supplying it to createStore()
is not enough, and is not meant to be a way to define the initial state in code.