Migrating Redux reducers to Rematch reducers
Rematch models contain a state
property, a reducers
property, and an effects
property. We can use state
to add the initial state, and inside reducers
, we can move our Redux reducers directly to the reducers' model
property:
const INITAL_STATE = { todos: [] } function reducer(state = INITAL_STATE, action) { switch(action.type) { case "ADD_TODO": { const newTodo = { id: Date.now(), title: action.title, completed: false, } return { ...state, todos: [...state.todos, newTodo] } ...