Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Creating the Store with configureStore | Setting Up Redux Toolkit in a React App
Gestion d'État avec Redux Toolkit dans React

bookCreating the Store with configureStore

Glissez pour afficher le menu

The store is the place where your application state lives.

In Redux Toolkit, you create it using configureStore. This function sets up everything for you with sensible defaults, so you don't have to deal with complex configuration.

Creating the Store

Open your store file and define the store:

import { configureStore } from '@reduxjs/toolkit';

export const store = configureStore({
  reducer: {}
});

Right now, the store is empty. You will add actual state logic using slices in the next chapters.

What configureStore Does

You don't need to configure everything manually.

configureStore already:

  • Sets up Redux DevTools;
  • Enables good defaults for development;
  • Prepares the store to work with async logic.

This is why Redux Toolkit is much simpler than older Redux setups.

How to Think About the Store

The store is a single place that holds your global state. Instead of storing data inside many components, you move important state into the store. Components then read from it and update it through defined actions.

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 2

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

Section 2. Chapitre 2
some-alt