Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
front:stockage_de_donnees [2025/09/29 10:53] – [Monter son Redux store] paolo | front:stockage_de_donnees [2025/09/29 16:42] (Version actuelle) – [Utiliser les actions] paolo | ||
---|---|---|---|
Ligne 11: | Ligne 11: | ||
* '' | * '' | ||
* '' | * '' | ||
+ | |||
### Monter son Redux store | ### Monter son Redux store | ||
Ligne 48: | Ligne 49: | ||
``` | ``` | ||
- | * On combine | + | * Nous combinons |
``` | ``` | ||
+ | // src/ | ||
+ | |||
import sessionReducer from " | import sessionReducer from " | ||
Ligne 60: | Ligne 64: | ||
}); | }); | ||
- | export const redux = configureStore({ reducer: rootReducer }); | + | export const reduxStore |
``` | ``` | ||
- | On peut aussi exporter toutes les actions du slice dans l' | + | Les actions du slice peuvent aussi être exportées |
``` | ``` | ||
Ligne 69: | Ligne 73: | ||
``` | ``` | ||
- | - On passe ce store à ''< | + | - Ce store est passé au ''< |
``` | ``` | ||
+ | // src/ | ||
+ | |||
import { Provider } from " | import { Provider } from " | ||
- | import { redux } from " | + | import { reduxStore |
export const ReduxProvider = (props) => { | export const ReduxProvider = (props) => { | ||
Ligne 79: | Ligne 85: | ||
return ( | return ( | ||
- | < | + | < |
{children} | {children} | ||
</ | </ | ||
Ligne 86: | Ligne 92: | ||
``` | ``` | ||
``` | ``` | ||
+ | // src/App.jsx | ||
+ | |||
import { Router } from " | import { Router } from " | ||
import { ReduxProvider } from " | import { ReduxProvider } from " | ||
Ligne 97: | Ligne 105: | ||
}; | }; | ||
``` | ``` | ||
- | Maintenant | + | Désormais |
. | . | ||
### Utiliser l' | ### Utiliser l' | ||
- | Pour récupérer l' | + | Pour récupérer l' |
- | Maintenant | + | Maintenant |
``` | ``` | ||
+ | // src/ | ||
+ | |||
import { Outlet, Navigate } from " | import { Outlet, Navigate } from " | ||
import { useSelector } from " | import { useSelector } from " | ||
Ligne 116: | Ligne 126: | ||
``` | ``` | ||
``` | ``` | ||
+ | // src/ | ||
+ | |||
import { Outlet, Navigate } from " | import { Outlet, Navigate } from " | ||
import { useSelector } from " | import { useSelector } from " | ||
Ligne 126: | Ligne 138: | ||
``` | ``` | ||
- | Vous êtes maintenant | + | Nous sommes |
+ | . | ||
### Utiliser les actions | ### Utiliser les actions | ||
Ligne 132: | Ligne 145: | ||
``` | ``` | ||
+ | // src/ | ||
+ | |||
import { Input } from " | import { Input } from " | ||
import { useDispatch } from " | import { useDispatch } from " | ||
import { setSession } from " | import { setSession } from " | ||
+ | import { API_URL } from " | ||
export const Login = () => { | export const Login = () => { |