diff --git a/src/content/reference/react/useTransition.md b/src/content/reference/react/useTransition.md
index 6533a201b..ada17a4e5 100644
--- a/src/content/reference/react/useTransition.md
+++ b/src/content/reference/react/useTransition.md
@@ -1,10 +1,17 @@
---
title: useTransition
+translationStatus: ai-draft
---
+
+
+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/useTransition.md).
+
+
+
-`useTransition` is a React Hook that lets you render a part of the UI in the background.
+`useTransition` è un Hook React che ti permette di renderizzare una parte dell'UI in background.
```js
const [isPending, startTransition] = useTransition()
@@ -20,7 +27,7 @@ const [isPending, startTransition] = useTransition()
### `useTransition()` {/*usetransition*/}
-Call `useTransition` at the top level of your component to mark some state updates as Transitions.
+Chiama `useTransition` al top level del tuo componente per contrassegnare alcuni aggiornamenti di state come Transizioni.
```js
import { useTransition } from 'react';
@@ -31,24 +38,24 @@ function TabContainer() {
}
```
-[See more examples below.](#usage)
+[Vedi altri esempi sotto.](#usage)
#### Parameters {/*parameters*/}
-`useTransition` does not take any parameters.
+`useTransition` non accetta parametri.
#### Returns {/*returns*/}
-`useTransition` returns an array with exactly two items:
+`useTransition` restituisce un array con esattamente due elementi:
-1. The `isPending` flag that tells you whether there is a pending Transition.
-2. The [`startTransition` function](#starttransition) that lets you mark updates as a Transition.
+1. Il flag `isPending` che ti indica se c'è una Transizione in sospeso.
+2. La [funzione `startTransition`](#starttransition) che ti permette di contrassegnare gli aggiornamenti come Transizione.
---
### `startTransition(action)` {/*starttransition*/}
-The `startTransition` function returned by `useTransition` lets you mark an update as a Transition.
+La funzione `startTransition` restituita da `useTransition` ti permette di contrassegnare un aggiornamento come Transizione.
```js {6,8}
function TabContainer() {
@@ -65,9 +72,9 @@ function TabContainer() {
```
-#### Functions called in `startTransition` are called "Actions". {/*functions-called-in-starttransition-are-called-actions*/}
+#### Le funzioni chiamate in `startTransition` si chiamano "Action". {/*functions-called-in-starttransition-are-called-actions*/}
-The function passed to `startTransition` is called an "Action". By convention, any callback called inside `startTransition` (such as a callback prop) should be named `action` or include the "Action" suffix:
+La funzione passata a `startTransition` si chiama "Action". Per convenzione, qualsiasi callback chiamata all'interno di `startTransition` (come una callback prop) dovrebbe chiamarsi `action` o includere il suffisso "Action":
```js {1,9}
function SubmitButton({ submitAction }) {
@@ -95,35 +102,35 @@ function SubmitButton({ submitAction }) {
#### Parameters {/*starttransition-parameters*/}
-* `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 that are 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](#react-doesnt-treat-my-state-update-after-await-as-a-transition)). State updates marked as Transitions will be [non-blocking](#perform-non-blocking-updates-with-actions) and [will not display unwanted loading indicators](#preventing-unwanted-loading-indicators).
+* `action`: Una funzione che aggiorna lo state chiamando una o più [funzioni `set`](/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 funzione `set` dopo `await` in un ulteriore `startTransition` (vedi [Troubleshooting](#react-doesnt-treat-my-state-update-after-await-as-a-transition)). Gli aggiornamenti di state contrassegnati come Transizioni saranno [non bloccanti](#perform-non-blocking-updates-with-actions) e [non mostreranno indicatori di caricamento indesiderati](#preventing-unwanted-loading-indicators).
#### Returns {/*starttransition-returns*/}
-`startTransition` does not return anything.
+`startTransition` non restituisce nulla.
#### Caveats {/*starttransition-caveats*/}
-* `useTransition` is a Hook, so it can only be called inside components or custom Hooks. If you need to start a Transition somewhere else (for example, from a data library), call the standalone [`startTransition`](/reference/react/startTransition) instead.
+* `useTransition` è un Hook, quindi può essere chiamato solo all'interno di componenti o custom Hook. Se devi avviare una Transizione altrove (per esempio, da una libreria di dati), chiama invece la funzione standalone [`startTransition`](/reference/react/startTransition).
-* 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 value, try [`useDeferredValue`](/reference/react/useDeferredValue) instead.
+* Puoi avvolgere un aggiornamento in una Transizione solo se hai accesso alla funzione `set` 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).
-* 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.
+* 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.
-* 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](#react-doesnt-treat-my-state-update-after-await-as-a-transition)).
+* 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](#react-doesnt-treat-my-state-update-after-await-as-a-transition)).
-* The `startTransition` function has a stable identity, so you will often see it omitted from Effect dependencies, but including it will not cause the Effect to fire. If the linter lets you omit a dependency without errors, it is safe to do. [Learn more about removing Effect dependencies.](/learn/removing-effect-dependencies#move-dynamic-objects-and-functions-inside-your-effect)
+* La funzione `startTransition` ha un'identità stabile, quindi spesso la vedrai omessa dalle dipendenze degli Effetti, ma includerla non farà scattare l'Effetto. Se il linter ti permette di omettere una dipendenza senza errori, puoi farlo in sicurezza. [Scopri di più sulla rimozione delle dipendenze degli Effetti.](/learn/removing-effect-dependencies#move-dynamic-objects-and-functions-inside-your-effect)
-* 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 update.
+* 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.
-* Transition updates can't be used to control text inputs.
+* Gli aggiornamenti Transizione non possono essere usati per controllare input di testo.
-* If there are multiple ongoing Transitions, React currently batches them together. This is a limitation that may be removed in a future release.
+* Se ci sono più Transizioni in corso, React attualmente le raggruppa insieme. Questa è una limitazione che potrebbe essere rimossa in una release futura.
## Usage {/*usage*/}
-### Perform non-blocking updates with Actions {/*perform-non-blocking-updates-with-actions*/}
+### Eseguire aggiornamenti non bloccanti con le Action {/*perform-non-blocking-updates-with-actions*/}
-Call `useTransition` at the top of your component to create Actions, and access the pending state:
+Chiama `useTransition` in cima al tuo componente per creare Action e accedere allo state pending:
```js [[1, 4, "isPending"], [2, 4, "startTransition"]]
import {useState, useTransition} from 'react';
@@ -134,12 +141,12 @@ function CheckoutForm() {
}
```
-`useTransition` returns an array with exactly two items:
+`useTransition` restituisce un array con esattamente due elementi:
-1. The `isPending` flag that tells you whether there is a pending Transition.
-2. The `startTransition` function that lets you create an Action.
+1. Il flag `isPending` che ti indica se c'è una Transizione in sospeso.
+2. La funzione `startTransition` che ti permette di creare un'Action.
-To start a Transition, pass a function to `startTransition` like this:
+Per avviare una Transizione, passa una funzione a `startTransition` così:
```js
import {useState, useTransition} from 'react';
@@ -161,17 +168,17 @@ function CheckoutForm() {
}
```
-The function passed to `startTransition` is called the "Action". You can update state and (optionally) perform side effects within an Action, and the work will be done in the background without blocking user interactions on the page. A Transition can include multiple Actions, and while a Transition is in progress, your UI stays responsive. For example, if the user clicks a tab but then changes their mind and clicks another tab, the second click will be immediately handled without waiting for the first update to finish.
+La funzione passata a `startTransition` si chiama "Action". Puoi aggiornare lo state e (opzionalmente) eseguire effetti collaterali all'interno di un'Action, e il lavoro verrà svolto in background senza bloccare le interazioni dell'utente sulla pagina. Una Transizione può includere più Action, e mentre una Transizione è in corso, la tua UI resta reattiva. Per esempio, se l'utente clicca una tab ma poi cambia idea e ne clicca un'altra, il secondo click verrà gestito immediatamente senza attendere il completamento del primo aggiornamento.
-To give the user feedback about in-progress Transitions, the `isPending` state switches to `true` at the first call to `startTransition`, and stays `true` until all Actions complete and the final state is shown to the user. Transitions ensure side effects in Actions to complete in order to [prevent unwanted loading indicators](#preventing-unwanted-loading-indicators), and you can provide immediate feedback while the Transition is in progress with `useOptimistic`.
+Per dare all'utente un feedback sulle Transizioni in corso, lo state `isPending` passa a `true` alla prima chiamata a `startTransition` e resta `true` finché tutte le Action non sono completate e lo state finale viene mostrato all'utente. Le Transizioni assicurano che gli effetti collaterali nelle Action si completino in ordine per [prevenire indicatori di caricamento indesiderati](#preventing-unwanted-loading-indicators), e puoi fornire un feedback immediato mentre la Transizione è in corso con `useOptimistic`.
-
+
-#### Updating the quantity in an Action {/*updating-the-quantity-in-an-action*/}
+#### Aggiornare la quantità in un'Action {/*updating-the-quantity-in-an-action*/}
-In this example, the `updateQuantity` function simulates a request to the server to update the item's quantity in the cart. This function is *artificially slowed down* so that it takes at least a second to complete the request.
+In questo esempio, la funzione `updateQuantity` simula una richiesta al server per aggiornare la quantità dell'articolo nel carrello. Questa funzione è *artificialmente rallentata* in modo che impieghi almeno un secondo per completare la richiesta.
-Update the quantity multiple times quickly. Notice that the pending "Total" state is shown while any requests are in progress, and the "Total" updates only after the final request is complete. Because the update is in an Action, the "quantity" can continue to be updated while the request is in progress.
+Aggiorna la quantità più volte in rapida successione. Nota che lo state pending "Total" viene mostrato mentre le richieste sono in corso, e "Total" si aggiorna solo dopo che l'ultima richiesta è completata. Poiché l'aggiornamento è in un'Action, la "quantity" può continuare ad essere aggiornata mentre la richiesta è in corso.
@@ -201,8 +208,8 @@ export default function App({}) {
const [isPending, startTransition] = useTransition();
const updateQuantityAction = async newQuantity => {
- // To access the pending state of a transition,
- // call startTransition again.
+ // Per accedere allo state pending di una Transizione,
+ // chiama di nuovo startTransition.
startTransition(async () => {
const savedQuantity = await updateQuantity(newQuantity);
startTransition(() => {
@@ -227,7 +234,7 @@ import { startTransition } from "react";
export default function Item({action}) {
function handleChange(event) {
- // To expose an action prop, await the callback in startTransition.
+ // Per esporre una prop action, fai await alla callback in startTransition.
startTransition(async () => {
await action(event.target.value);
})
@@ -268,7 +275,7 @@ export default function Total({quantity, isPending}) {
```js src/api.js
export async function updateQuantity(newQuantity) {
return new Promise((resolve, reject) => {
- // Simulate a slow network request.
+ // Simula una richiesta di rete lenta.
setTimeout(() => {
resolve(newQuantity);
}, 2000);
@@ -305,22 +312,22 @@ export async function updateQuantity(newQuantity) {
-This is a basic example to demonstrate how Actions work, but this example does not handle requests completing out of order. When updating the quantity multiple times, it's possible for the previous requests to finish after later requests causing the quantity to update out of order. This is a known limitation that we will fix in the future (see [Troubleshooting](#my-state-updates-in-transitions-are-out-of-order) below).
+Questo è un esempio base per dimostrare come funzionano le Action, ma non gestisce richieste che si completano fuori ordine. Quando aggiorni la quantità più volte, è possibile che le richieste precedenti finiscano dopo quelle successive, causando un aggiornamento della quantità fuori ordine. Questa è una limitazione nota che correggeremo in futuro (vedi [Troubleshooting](#my-state-updates-in-transitions-are-out-of-order) sotto).
-For common use cases, React provides built-in abstractions such as:
+Per casi d'uso comuni, React fornisce astrazioni integrate come:
- [`useActionState`](/reference/react/useActionState)
-- [`