You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/reference/react/startTransition.md
+25-18Lines changed: 25 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,17 @@
1
1
---
2
2
title: startTransition
3
+
translationStatus: ai-draft
3
4
---
4
5
6
+
<Note>
7
+
8
+
Questa pagina è stata tradotta automaticamente e supervisionata da un maintainer. Un'ulteriore revisione da parte della community sarebbe comunque utile. [Migliora questa traduzione](https://github.com/reactjs/it.react.dev/edit/main/src/content/reference/react/startTransition.md).
9
+
10
+
</Note>
11
+
5
12
<Intro>
6
13
7
-
`startTransition`lets you render a part of the UI in the background.
14
+
`startTransition`ti permette di renderizzare una parte dell'UI in background.
The `startTransition`function lets you mark a state update as a Transition.
30
+
La funzione `startTransition`ti permette di contrassegnare un aggiornamento di state come una Transizione.
24
31
25
32
```js {7,9}
26
33
import { startTransition } from'react';
@@ -37,39 +44,39 @@ function TabContainer() {
37
44
}
38
45
```
39
46
40
-
[See more examples below.](#usage)
47
+
[Vedi altri esempi sotto.](#usage)
41
48
42
49
#### Parameters {/*parameters*/}
43
50
44
-
*`action`: A function that updates some state by calling one or more [`set` functions](/reference/react/useState#setstate). React calls`action`immediately with no parameters and marks all state updates scheduled synchronously during the `action` function call as Transitions. Any async calls awaited in the `action`will be included in the transition, but currently require wrapping any `set`functions after the `await` in an additional`startTransition` (see[Troubleshooting](/reference/react/useTransition#react-doesnt-treat-my-state-update-after-await-as-a-transition)). State updates marked as Transitions will be [non-blocking](#marking-a-state-update-as-a-non-blocking-transition)and [will not display unwanted loading indicators.](/reference/react/useTransition#preventing-unwanted-loading-indicators).
51
+
*`action`: Una funzione che aggiorna dello state chiamando una o più [`set` functions](/reference/react/useState#setstate). React chiama`action`immediatamente senza parametri e contrassegna come Transizioni tutti gli aggiornamenti di state pianificati in modo sincrono durante la chiamata alla funzione `action`. Qualsiasi chiamata async attesa con `await`in `action`sarà inclusa nella Transizione, ma attualmente richiede di avvolgere qualsiasi `set`function dopo `await` in un ulteriore`startTransition` (vedi[Troubleshooting](/reference/react/useTransition#react-doesnt-treat-my-state-update-after-await-as-a-transition)). Gli aggiornamenti di state contrassegnati come Transizioni saranno [non bloccanti](#marking-a-state-update-as-a-non-blocking-transition)e [non mostreranno indicatori di caricamento indesiderati.](/reference/react/useTransition#preventing-unwanted-loading-indicators)
45
52
46
53
#### Returns {/*returns*/}
47
54
48
-
`startTransition`does not return anything.
55
+
`startTransition`non restituisce nulla.
49
56
50
57
#### Caveats {/*caveats*/}
51
58
52
-
*`startTransition`does not provide a way to track whether a Transition is pending. To show a pending indicator while the Transition is ongoing, you need [`useTransition`](/reference/react/useTransition)instead.
59
+
*`startTransition`non fornisce un modo per tracciare se una Transizione è in corso. Per mostrare un indicatore di pending mentre la Transizione è in corso, hai bisogno di [`useTransition`](/reference/react/useTransition)al suo posto.
53
60
54
-
*You can wrap an update into a Transition only if you have access to the `set` function of that state. If you want to start a Transition in response to some prop or a custom Hook return value, try[`useDeferredValue`](/reference/react/useDeferredValue) instead.
61
+
*Puoi avvolgere un aggiornamento in una Transizione solo se hai accesso alla `set` function di quello state. Se vuoi avviare una Transizione in risposta a una prop o a un valore di un custom Hook, prova[`useDeferredValue`](/reference/react/useDeferredValue).
55
62
56
-
*The function you pass to`startTransition`is called immediately, marking all state updates that happen while it executes as Transitions. If you try to perform state updates in a`setTimeout`, for example, they won't be marked as Transitions.
63
+
*La funzione che passi a`startTransition`viene chiamata immediatamente, contrassegnando come Transizioni tutti gli aggiornamenti di state che avvengono mentre viene eseguita. Se provi a eseguire aggiornamenti di state in un`setTimeout`, per esempio, non saranno contrassegnati come Transizioni.
57
64
58
-
*You must wrap any state updates after any async requests in another `startTransition`to mark them as Transitions. This is a known limitation that we will fix in the future (see[Troubleshooting](/reference/react/useTransition#react-doesnt-treat-my-state-update-after-await-as-a-transition)).
65
+
*Devi avvolgere qualsiasi aggiornamento di state dopo richieste async in un altro `startTransition`per contrassegnarli come Transizioni. Questa è una limitazione nota che correggeremo in futuro (vedi[Troubleshooting](/reference/react/useTransition#react-doesnt-treat-my-state-update-after-await-as-a-transition)).
59
66
60
-
*A state update marked as a Transition will be interrupted by other state updates. For example, if you update a chart component inside a Transition, but then start typing into an input while the chart is in the middle of a re-render, React will restart the rendering work on the chart component after handling the input state update.
67
+
*Un aggiornamento di state contrassegnato come Transizione verrà interrotto da altri aggiornamenti di state. Per esempio, se aggiorni un componente grafico all'interno di una Transizione, ma poi inizi a digitare in un input mentre il grafico è nel mezzo di una ri-renderizzazione, React riavvierà il lavoro di renderizzazione sul componente grafico dopo aver gestito l'aggiornamento dell'input.
61
68
62
-
*Transition updates can't be used to control text inputs.
69
+
*Gli aggiornamenti Transizione non possono essere usati per controllare input di testo.
63
70
64
-
*If there are multiple ongoing Transitions, React currently batches them together. This is a limitation that may be removed in a future release.
71
+
*Se ci sono più Transizioni in corso, React attualmente le raggruppa insieme. Questa è una limitazione che potrebbe essere rimossa in una release futura.
65
72
66
73
---
67
74
68
75
## Usage {/*usage*/}
69
76
70
-
### Marking a state update as a non-blocking Transition {/*marking-a-state-update-as-a-non-blocking-transition*/}
77
+
### Contrassegnare un aggiornamento di state come Transizione non bloccante {/*marking-a-state-update-as-a-non-blocking-transition*/}
71
78
72
-
You can mark a state update as a *Transition* by wrapping it in a `startTransition` call:
79
+
Puoi contrassegnare un aggiornamento di state come una *Transizione* avvolgendolo in una chiamata a `startTransition`:
73
80
74
81
```js {7,9}
75
82
import { startTransition } from'react';
@@ -86,14 +93,14 @@ function TabContainer() {
86
93
}
87
94
```
88
95
89
-
Transitions let you keep the user interface updates responsive even on slow devices.
96
+
Le Transizioni ti permettono di mantenere reattivi gli aggiornamenti dell'interfaccia utente anche su dispositivi lenti.
90
97
91
-
With a Transition, your UI stays responsive in the middle of a re-render. For example, if the user clicks a tab but then change their mind and click another tab, they can do that without waiting for the first re-render to finish.
98
+
Con una Transizione, la tua UI resta reattiva nel mezzo di una ri-renderizzazione. Per esempio, se l'utente clicca una tab ma poi cambia idea e clicca un'altra tab, può farlo senza attendere che la prima ri-renderizzazione sia completata.
92
99
93
100
<Note>
94
101
95
-
`startTransition`is very similar to[`useTransition`](/reference/react/useTransition), except that it does not provide the `isPending`flag to track whether a Transition is ongoing. The standalone function is also not associated with a component, so if the function passed to it throws an error or returns a rejected Promise, React reports the error with [`reportError`](https://developer.mozilla.org/en-US/docs/Web/API/Window/reportError). You can call `startTransition`when`useTransition`is not available. For example, `startTransition`works outside components, such as from a data library.
102
+
`startTransition`è molto simile a[`useTransition`](/reference/react/useTransition), tranne per il fatto che non fornisce il flag `isPending`per tracciare se una Transizione è in corso. La funzione standalone non è inoltre associata a un componente, quindi se la funzione passata lancia un errore o restituisce una Promise rifiutata, React segnala l'errore con [`reportError`](https://developer.mozilla.org/it/docs/Web/API/Window/reportError). Puoi chiamare `startTransition`quando`useTransition`non è disponibile. Per esempio, `startTransition`funziona fuori dai componenti, ad esempio da una libreria dati.
96
103
97
-
[Learn about Transitions and see examples on the `useTransition` page.](/reference/react/useTransition)
104
+
[Scopri di più sulle Transizioni e vedi esempi nella pagina `useTransition`.](/reference/react/useTransition)
0 commit comments