Installing and Using Redux
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 ...
Get Modern Front-End Development for Rails, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.