Make combineReducers more flexible about additional reducers' arguments #879
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi, a couple of days ago, when searching for an answer to my problem with inaccessible state data inside of nested reducers (created with
combineReducers
and other helpers), I've found a similar question with a solution/proposition to pass down additional arguments to the reducers, with required data to calculate state change.Unfortunately,
combineReducers
generates combined reducer, which do not pass any arguments besides the previous state and any passed action to the nested reducers. My PR fixes this problem by simply passing "rest" of the arguments to other reducers (using spread operator).I hope this is a valuable change to the code-base (well, it definitely helped me a lot to decouple my code into smaller chunks), if there is anything else to do about it (like changing the docs or writing some tests), please just let me know.