September 2022
Intermediate to advanced
410 pages
10h 7m
English
We first need to install Redux, and the Redux binding for React:
| | $ yarn add @reduxjs/toolkit react-redux |
The current recommended way to use Redux is through the toolkit package at @reduxjs/toolkit, which provides a more useful API for creating Redux reducers. The core Redux package and the TypeScript definitions will be loaded as a dependency of these packages automatically.
I should note that the new version of Redux triggered TypeScript errors that I was only able to clear by adding the setting "allowSyntheticDefaultImports": true to the compilerOptions section of tsconfig.json—I’m not completely sure why this only triggered on the newest versions, but it has to do with allowing lines like import React from "react" ...