UNPKG

redux-shelf

Version:

Helper reducers and actions to take away your boilerplate code from both Data and Communication state types

27 lines (21 loc) 530 B
import { methods } from './constants'; export default function content(state = {}, action) { switch (action.meta.method) { case methods.REMOVE: { if (!state[action.meta.selector]) { return state; } const { [`${action.meta.selector}`]: omit, ...newState } = state; return newState; } case methods.SET: return action.payload.content; case methods.UPDATE: return { ...state, ...action.payload.content, }; default: return state; } }