You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Combines reducers from redux-ducks modules into a single reducer.
It uses reducers defined as ducks, see
ducks-modular-redux
(aka isolated modules), and creates a reducer
combining their reducers with
combineReducers.
Quick Use
Install with npm:
npm install ducks-reducer
importducksReducerfrom'ducks-reducer'import*ascommentsfrom'./comments'import*aspostsfrom'./posts'import*asusersfrom'./users'constreducer=ducksReducer({ comments, posts, users })// ...do your stuff...conststore=createStore(reducer,preloadedState,enhancer)// ...do your stuff...
ducksReducer(ducks)
It creates a reducer with combineReducers with all the reducers
of the given reducers.
By default, it assumes that ducks are esModules and it looks for
the default property which is suposed to be the reducer:
constreducer=ducksReducer({ comments, posts, users })// ^ this is equivalent to vconstreducer=combineReducers({comments: comments.default,posts: posts.default,users: users.default,})
If default is not found in any duck, then it assumes that it may be
an ES5 module. Then it looks for the duck itself, if it is a function,
then it is considered the reducer.
constreducer=ducksReducer({ comments, posts, users })// ^ this is equivalent to vconstreducer=combineReducers({ comments, posts, users })
If the duck does not have a default and the duck itself is not a function,
then it assumes that there is no reducer for that duck.
It supports to combine all three kinds of ducks
(es6 modules, es5 modules and with no reducer).
constreducer=ducksReducer({ comments, posts, users })// ^ this is equivalent to vconstreducer=combineReducers({comments: comments.default,// it was es6 moduleposts: posts,// it was es5 module// users had no reducer})