UNPKG

redux-undo-actions

Version:

Redux middleware for undo/redo actions by dispatching reverting action

21 lines (18 loc) 466 B
import * as types from './types'; const reducer = (state = [], action) => { switch (action.type) { case types.CREATE: return [ ...state, { id: action.id, text: action.text } ]; case types.REMOVE: return state.filter(el => el.id !== action.id); default: return state; } }; export default reducer;