UNPKG

redux-state-sync

Version:

A middleware for redux to sync state in different tabs

19 lines (18 loc) 517 B
const todos = (state = [], action) => { switch (action.type) { case 'ADD_TODO': return [ ...state, { id: action.id, text: action.text, completed: false, }, ]; case 'TOGGLE_TODO': return state.map(todo => (todo.id === action.id ? { ...todo, completed: !todo.completed } : todo)); default: return state; } }; export default todos;