Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Reduce multiple reducers into a single reducer from left to right

License

NotificationsYou must be signed in to change notification settings

redux-utilities/reduce-reducers

Repository files navigation

Build Statusnpm Versionnpm Downloads Monthly

Reduce multiple reducers into a single reducer from left to right

Install

npm install reduce-reducers

Usage

importreduceReducersfrom'reduce-reducers';constinitialState={A:0,B:0};constaddReducer=(state,payload)=>({ ...state,A:state.A+payload});constmultReducer=(state,payload)=>({ ...state,B:state.B*payload});constreducer=reduceReducers(initialState,addReducer,multReducer);conststate={A:1,B:2};constpayload=3;reducer(state,payload);// { A: 4, B: 6 }

FAQ

Why?

Originally created to combine multiple Redux reducers that correspond to different actions (e.g.like this). Technically works with any reducer, not just with Redux, though I don't know of any other use cases.

What is the difference betweenreduceReducers andcombineReducers?

This StackOverflow post explains it very well:https://stackoverflow.com/a/44371190/5741172

About

Reduce multiple reducers into a single reducer from left to right

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors9


[8]ページ先頭

©2009-2025 Movatter.jp