FWIW, this process can be simplified greatly, on several levels.
First, we already have a Redux+TS template for Create-React-App: github.com/reduxjs/cra-template-redux-typescript . It comes with Redux Toolkit and React-Redux already configured.
Second, the examples here are actually going against how we recommend writing Redux code.
- Redux Toolkit is installed, but it's not being used at all to write the reducers
- You should be using the
createSlice API, which will also auto-generate the action creators for you
createSlice uses Immer inside, so you can "mutate" the state inside of the reducer instead of having to write spread operations for immutable updates
- The logic should be organized into single-file "slice" files per feature - no need for separate "actions" and "action-creators" files.
Please see these resources for our guidelines on how to write Redux code correctly:
FWIW, this process can be simplified greatly, on several levels.
First, we already have a Redux+TS template for Create-React-App: github.com/reduxjs/cra-template-redux-typescript . It comes with Redux Toolkit and React-Redux already configured.
Second, the examples here are actually going against how we recommend writing Redux code.
createSliceAPI, which will also auto-generate the action creators for youcreateSliceuses Immer inside, so you can "mutate" the state inside of the reducer instead of having to write spread operations for immutable updatesPlease see these resources for our guidelines on how to write Redux code correctly: