angular-redux / form

Keep your Angular2+ form state in Redux
MIT License
41 stars 15 forks source link

`composeReducers` vs. `combineReducers` #6

Closed SethDavenport closed 6 years ago

SethDavenport commented 7 years ago

angular-redux/form exposes a composeReducers function. Can you elaborate on what this does that isn't normally handled via Redux's existing combineReducers?

SethDavenport commented 7 years ago

When I use composerReducers as in the docs I get this warning. Still works though.

screen shot 2017-01-29 at 1 00 31 am
Pierrebleroux commented 7 years ago

+1 on the warning, would love to get rid of it.

yadielar commented 7 years ago

For anyone who would like to remove the warning, for now, a workaround I use is to include the property name in the combineReducers map object with a pass through reducer function, like this:

// Use whenever you need to declare a form reducer path prop
export const formReducer = (state = {}) => state;

const rootReducer = combineReducers({
  reducerA,
  reducerB,
  myForm: formReducer,
});
smithad15 commented 6 years ago

Thanks for the work around for the console message. I believe that the initial intent of the function was to be able to wrap your entire state so that the selector for connect could merge with any portion of the state tree. I don't see this being a particularly safe or common practice as usually one would want to isolate the state of a form under a top-level property, in which case combineReducers would be all you would need. A more simple formsReducer API is forthcoming.