-
Notifications
You must be signed in to change notification settings - Fork 84
Scaling Up With Reducer and Context #525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perdona il ritardo! 🙈
Qualche piccola correzione
@@ -897,11 +897,11 @@ ul, li { margin: 0; padding: 0; } | |||
|
|||
</Sandpack> | |||
|
|||
**The state still "lives" in the top-level `TaskApp` component, managed with `useReducer`.** But its `tasks` and `dispatch` are now available to every component below in the tree by importing and using these contexts. | |||
**Lo stato ancora "vive" nel componente di primo livello `TaskApp`, gestito con `useReducer`.** Ma i suoi `tasks` e `dispatch` sono ora disponibili ad ogni componente nell'albero sottostante semplicemente importando e usando questi context. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cosa ne pensi?
**Lo stato ancora "vive" nel componente di primo livello `TaskApp`, gestito con `useReducer`.** Ma i suoi `tasks` e `dispatch` sono ora disponibili ad ogni componente nell'albero sottostante semplicemente importando e usando questi context. | |
**Lo stato continua a "vivere" nel componente di primo livello `TaskApp`, gestito con `useReducer`.** Ma i suoi `tasks` e `dispatch` sono ora disponibili ad ogni componente nell'albero sottostante semplicemente importando e usando questi context. |
"tags": [ | ||
"advanced" | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"tags": [ | |
"advanced" | |
], | |
"tags": ["advanced"], |
"tags": [ | ||
"intermediate" | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"tags": [ | |
"intermediate" | |
], | |
"tags": ["intermediate"], |
- Puoi esportare un componente come `TasksProvider` che fornisce il context. | ||
- Puoi anche esportare dei Ganci personalizzati come `useTasks` e `useTasksDispatch` per leggerlo. | ||
- Puoi avere molte coppie context-reducer come questa nella tua app. | ||
- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- |
|
||
The `useReducer` Hook returns the current `tasks` and the `dispatch` function that lets you update them: | ||
Il gancio `useReducer` ritorna le `tasks` attuali e la funzione `dispatch` che ti permette di aggiornarle: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Il gancio `useReducer` ritorna le `tasks` attuali e la funzione `dispatch` che ti permette di aggiornarle: | |
L'hook `useReducer` ritorna le `tasks` attuali e la funzione `dispatch` che ti permette di aggiornarle: |
|
||
<Note> | ||
|
||
Functions like `useTasks` and `useTasksDispatch` are called *[Custom Hooks.](/learn/reusing-logic-with-custom-hooks)* Your function is considered a custom Hook if its name starts with `use`. This lets you use other Hooks, like `useContext`, inside it. | ||
Funzioni come `useTasks` e `useTasksDispatch` sono chiamate *[Ganci Personalizzati.](/learn/reusing-logic-with-custom-hooks)* La tua funzione è considerata un Gancio personalizzato se il nome comincia con `use`. Questo ti permette di usare altri Ganci, tipo `useContext`, dentro di esso. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Funzioni come `useTasks` e `useTasksDispatch` sono chiamate *[Ganci Personalizzati.](/learn/reusing-logic-with-custom-hooks)* La tua funzione è considerata un Gancio personalizzato se il nome comincia con `use`. Questo ti permette di usare altri Ganci, tipo `useContext`, dentro di esso. | |
Funzioni come `useTasks` e `useTasksDispatch` sono chiamate *[Hooks Personalizzati.](/learn/reusing-logic-with-custom-hooks)* La tua funzione è considerata un Hook personalizzato se il nome comincia con `use`. Questo ti permette di usare altri Hooks, tipo `useContext`, dentro di esso. |
3. Usa uno dei due context dai componente che ne hanno bisogno per leggerli. | ||
- Puoi ulteriormente ordinare i componenti muovendo tutte le connessioni in un unico file. | ||
- Puoi esportare un componente come `TasksProvider` che fornisce il context. | ||
- Puoi anche esportare dei Ganci personalizzati come `useTasks` e `useTasksDispatch` per leggerlo. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Puoi anche esportare dei Ganci personalizzati come `useTasks` e `useTasksDispatch` per leggerlo. | |
- Puoi anche esportare degli Hooks personalizzati come `useTasks` e `useTasksDispatch` per leggerlo. |
There are a few words that I'm not sure whether I can translate or not but I'm looking forward to the review to see if there's something that can be improved