Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Understanding Actions Generated by Slices | Creating and Managing State with Slices
Gestion d'État avec Redux Toolkit dans React

bookUnderstanding Actions Generated by Slices

Glissez pour afficher le menu

When you create a slice, Redux Toolkit automatically generates actions for you. You don't need to define them manually.

How Actions Are Created

Each reducer you define becomes an action. For example, if you have:

increment(state) {
  state.value += 1;
}

Redux Toolkit creates an action called 'counter/increment'.

Using Actions

You can import and use these actions in your components:

import { increment } from './counterSlice';

dispatch(increment());

The action is sent to the store, and the corresponding reducer runs.

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 3. Chapitre 4

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 3. Chapitre 4
some-alt