redux combined reducers code example
Example 1: combine reducers redux
export default theDefaultReducer = (state = 0, action) => state
export const firstNamedReducer = (state = 1, action) => state
export const secondNamedReducer = (state = 2, action) => state
import { combineReducers, createStore } from 'redux'
import theDefaultReducer, {
firstNamedReducer,
secondNamedReducer
} from './reducers'
const rootReducer = combineReducers({
theDefaultReducer,
firstNamedReducer,
secondNamedReducer
})
const store = createStore(rootReducer)
console.log(store.getState())
Example 2: multiple reducers redux
import { createStore, combineReducers } from 'redux';
const rootReducer = combineReducers({
first: firstReducer,
second: secondReducer
});
const store = createStore(rootReducer);