indexiatech / redux-immutablejs

Redux Immutable facilities.
BSD 3-Clause "New" or "Revised" License
685 stars 36 forks source link

Issues with initialState when using combineReducers #18

Closed liorbrauer closed 8 years ago

liorbrauer commented 8 years ago

Similar to #10:

I am trying to init my store by calling a function initStore(initialState) like this (initialState is an Immutable.Map):


createStore = require('redux').createStore
combineReducers = require('redux-immutablejs').combineReducers

initStore = (initialState) ->
  mainReducer = combineReducers(reducers)
  store = createStore(mainReducer, initialState)

if I debug the last line, the store.getState() returns the default initialState of the reducer, not the initialState I am sending here to initStore(initialState).

It seems that combineReducers creates the reducers with their default initialState, which is expected, but calling redux's createStore with the initialState is not changing the state. What's the intended way to do so?

liorbrauer commented 8 years ago

Well, this is silly. I seem to have made a similar mistake as the author of #10. I did not contruct my initialState to be in the same structure as the output of combineReducers, i.e I forgot to construct it with the reducer's domain.

/Silly me.