Combinando funciones reductoras
const reducer = (state, action) => {
if (action.type == "...") {
// código
} else if (action.type == "...") {
// más código
}
// más else ifs, quizá decenas o cientos
}import { createStore, combineReducers } from "redux";
const reducer1 = (state={}, action) => {
// ...
return state;
}
const reducer2 = (state={}, action) => {
// ...
return state;
}
const store = createStore(combineReducers({ tasks: reducer1, users: reducer2 }));Last updated