Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

Fabs97
Copy link

@Fabs97 Fabs97 commented Nov 19, 2024

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

Copy link

vercel bot commented Nov 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
legacy-it-reactjs-org ⬜️ Ignored (Inspect) Visit Preview Nov 19, 2024 7:21am

Copy link
Collaborator

@deblasis deblasis left a 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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cosa ne pensi?

Suggested change
**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.

Comment on lines +176 to +178
"tags": [
"advanced"
],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"tags": [
"advanced"
],
"tags": ["advanced"],

Comment on lines +139 to +141
"tags": [
"intermediate"
],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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.
-
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-


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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
Copy link
Collaborator

@deblasis deblasis Mar 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Puoi anche esportare dei Ganci personalizzati come `useTasks` e `useTasksDispatch` per leggerlo.
- Puoi anche esportare degli Hooks personalizzati come `useTasks` e `useTasksDispatch` per leggerlo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants