Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nested combineReducers #22

Closed
mathisonian opened this issue Feb 22, 2016 · 5 comments
Closed

nested combineReducers #22

mathisonian opened this issue Feb 22, 2016 · 5 comments

Comments

@mathisonian
Copy link
Contributor

I'm having some trouble getting this library to work with my existing redux reducers. I believe the problem is that I am nesting multiple combineReducers calls in my root reducer.

So for a simplified example I have the following files:

// root-reducer.js
import { combineReducers } from 'redux-immutable';
import complexReducer from './complex-reducer';
export default combineReducers({
  complexReducer
});
// complex-reducer.js
import { combineReducers } from 'redux-immutable';
import reducerA from './reducer-a';
import reducerB from './reducer-b';
import reducerC from './reducer-c';

export default combineReducers({
  reducerA,
  reducerB,
  reducerC
});

When it tries to set the initial state of the complex reducer, it is passed in an undefined value from the root reducer and gives this error:

The previous state received by the reducer is of unexpected type. Expected argument to be an instance of Immutable.Iterable with the following properties: "reducerA", "reducerB", "reducerC".

and then fails on the withMutations call here because inputState is undefined.

This pattern is supported by redux (see reduxjs/redux#738). Is this possible in redux-immutable? Sorry if I am missing something obvious - am fairly new to the redux ecosystem.

@holymonson
Copy link

Met the same issue too. When nesting combineReducers, state would be undefined if no nested initialState provided. combineReducers from 'redux' can handle but this not, seems providing an default empty Immutable.Map when state === undefined would be a choice to fix it.

@gajus
Copy link
Owner

gajus commented Mar 1, 2016

Does anyone want to practise their PR skills?

@mathisonian
Copy link
Contributor Author

I'm happy to send a PR. Should be able to get something together today.

mathisonian added a commit to mathisonian/redux-immutable that referenced this issue Mar 1, 2016
@gajus
Copy link
Owner

gajus commented Mar 2, 2016

v3.0.6 has been published

@gajus gajus closed this as completed Mar 2, 2016
@mathisonian
Copy link
Contributor Author

thanks @gajus!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants