https://github.com/mainick/react-hook-usereducer
Esempi di utilizzo dell'hook React useReducer
https://github.com/mainick/react-hook-usereducer
react react-hook usereducer-hooks
Last synced: 10 months ago
JSON representation
Esempi di utilizzo dell'hook React useReducer
- Host: GitHub
- URL: https://github.com/mainick/react-hook-usereducer
- Owner: mainick
- Created: 2020-11-25T09:16:36.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2020-11-26T16:29:02.000Z (about 5 years ago)
- Last Synced: 2025-01-23T02:31:49.431Z (12 months ago)
- Topics: react, react-hook, usereducer-hooks
- Language: JavaScript
- Homepage:
- Size: 212 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Esempi React Hook useReducer
L'hook useState è ottimo per gestire lo stato semplice, ma se ti imbatti in oggetti di stato o transazioni di stato più complessi,
che vuoi mantenere **gestibili e prevedibili**, l'**hook useReducer** è un ottimo candidato per gestirli.
In questo esempio modifichiamo l'app delle cose da fare *todos* utilizzando l'hook useReducer.
Prima con un semplice esempio *AppHookReducerTodos* per dimostrare come è più prevedibile gestire le transazioni di stato rispetto a useState.
L'altro esempio più complesso *AppHookReducerNotications* dove il **reducer** viene utilizzato per gestire la modifica di un stato complesso del componente utilizzando transazioni di stato.
Importate il componente del relativo hook in *index.js* per vederlo in opera.
https://codesandbox.io/s/react-hook-usereducer-17c1g