I have three reducers
I have one combine reducer for above three. But I want to divide project structure into multiple reducers. Is it a good practice to have multiple combine reducer in the project?
Yes, you can have multiple combineReducers
in your App, You can at the top level combine reducers Home , Listing and Detail
and even split each individual reducers into multiple and combine them into one.
According to the Redux docs:
You may call
combineReducers
at any level of the reducer hierarchy. It doesn't have to happen at the top. In fact you may use it again to split the child reducers that get too complicated into independent grandchildren, and so on.
Some more description about combineReducer
:
As your app grows more complex, you'll want to split your reducing function into separate functions, each managing independent parts of the state.
The
combineReducers
helper function turns an object whose values are different reducing functions into a single reducing function you can pass tocreateStore
.The resulting reducer calls every child reducer, and gathers their results into a single state object. The shape of the state object matches the keys of the passed reducers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With