Duck
An example of /store/redux/app.js following re-duck style
Define `createReducer` helper
const createReducer = (initialState = {}, handlers = {}) => (state, action) => {
const nextState = produce(state, draft => {
if (handlers[action.type]) {
return handlers[action.type](draft, action)
}
})
return nextState
}Declare initial state
const initialState = {
locale: 'en',
theme: 'light',
}Declare action types
Declare action creators
Declare reducer
Declare selectors
Last updated
Was this helpful?