createReducer - rootstrap/redux-tools GitHub Wiki

createReducer lets you create a reducer from an object in which the keys represent the action type to be handled, and the values the function that handles them. It will also ensure immutability by using immer.

Remember that you can use the object created with createThunk as the keys of the reducer. Example:

import { createReducer } from '@rootstrap/redux-tools';
import { getEpisodes } from './actions'

const initialState = {
  episodes: [],
};

export default createReducer(initialState, {
  [getEpisodes.success]: (state, action) => {
    state.episodes = action.payload;
  },
  [getEpisodes.error]: (state) => {
    state.episodes = [];
  },
});