/exc.react-redux-toolkit

Redux Toolkit with React: A Simple Exercise This repository contains a straightforward exercise designed to help you learn and practice using Redux Toolkit with React. Perfect for beginners looking to understand state management in React applications.

Primary LanguageTypeScript

Redux Toolkit with React: A Simple Exercise

The ReduxToolkit part is based on the tutorial "Redux - Complete Tutorial (with Redux Toolkit)" by Cosden Solutions.

Base concepts of Redux:

  • Store: The state of the application
  • Actions: What the store can do
  • Reducers: How the state changes

Key points:

  • Redux never mutate the state directly. Instead, it returns a new state based on the previous state and an action. Similar to React's setState - we need to return a new object with different memory address.
  • ReduxToolkit automatically implements the same pattern under the hood.

See also:

React + TypeScript + Vite + Redux Toolkit

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

In addition in this boilerplate is added support for SASS and the current latest version of TypeScript - 5.5.2.

Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

  • Configure the top-level parserOptions property like this:
export default {
  // other rules...
  parserOptions: {
    ecmaVersion: 'latest',
    sourceType: 'module',
    project: ['./tsconfig.json', './tsconfig.node.json'],
    tsconfigRootDir: __dirname,
  },
}
  • Replace plugin:@typescript-eslint/recommended to plugin:@typescript-eslint/recommended-type-checked or plugin:@typescript-eslint/strict-type-checked
  • Optionally add plugin:@typescript-eslint/stylistic-type-checked
  • Install eslint-plugin-react and add plugin:react/recommended & plugin:react/jsx-runtime to the extends list