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-dom/hooks/useFormStatus.md
+42-42
Original file line number
Diff line number
Diff line change
@@ -5,13 +5,13 @@ canary: true
5
5
6
6
<Canary>
7
7
8
-
The `useFormStatus`Hook is currently only available in React's Canary and experimental channels. Learn more about [React's release channels here](/community/versioning-policy#all-release-channels).
8
+
El Hook `useFormStatus`está actualmente disponible solo en React Canary y canales experimentales. Aprende más sobre los [canales de lanzamiento de React aquí](/community/versioning-policy#all-release-channels).
9
9
10
10
</Canary>
11
11
12
12
<Intro>
13
13
14
-
`useFormStatus`is a Hook that gives you status information of the last form submission.
14
+
`useFormStatus`es un Hook que brinda información de estado del último formulario enviado.
@@ -47,42 +47,42 @@ export default function App() {
47
47
}
48
48
```
49
49
50
-
To get status information, the `Submit` component must be rendered within a `<form>`. The Hook returns information like the <CodeStepstep={1}>`pending`</CodeStep> property which tells you if the form is actively submitting.
50
+
Para obtener información de estado, el componente de `Enviar` tiene que ser renderizado dentro de un `<form>`. El Hook retorna información como la propiedad <CodeStepstep={1}>`pending`</CodeStep> que te dice si el formulario se está enviando activamente.
51
51
52
-
In the above example, `Submit` uses this information to disable `<button>`presses while the form is submitting.
52
+
En el ejemplo de arriba, `Enviar` usa esta información para deshabilitar la pulsación de `<button>`mientras el formulario se está enviando.
53
53
54
-
[See more examples below.](#usage)
54
+
[Ver más ejemplos abajo.](#usage)
55
55
56
-
#### Parameters {/*parameters*/}
56
+
#### Parámetros {/*parameters*/}
57
57
58
-
`useFormStatus`does not take any parameters.
58
+
`useFormStatus`no toma ningún parámetro.
59
59
60
-
#### Returns {/*returns*/}
60
+
#### Retorna {/*returns*/}
61
61
62
-
A `status`object with the following properties:
62
+
Un objeto de `status`con las siguientes propiedades:
63
63
64
-
*`pending`: A boolean. If `true`, this means the parent `<form>`is pending submission. Otherwise,`false`.
64
+
*`pending`: Un booleano. Si es `true` significa que el `<form>`padre está pendiente de enviarse. De otro modo es`false`.
65
65
66
-
*`data`: An object implementing the[`FormData interface`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)that contains the data the parent`<form>`is submitting. If there is no active submission or no parent`<form>`, it will be`null`.
66
+
*`data`:Un objeto que implementa la[`interfaz FormData`](https://developer.mozilla.org/es/docs/Web/API/FormData)que contiene los datos que el`<form>`padre está enviando. Si no hay ningún envío activo o no hay`<form>`, va a ser`null`.
67
67
68
-
*`method`: A string value of either `'get'`or`'post'`. This represents whether the parent `<form>`is submitting with either a `GET` or `POST`[HTTP method](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods). By default, a`<form>`will use the `GET`method and can be specified by the [`method`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#method) property.
68
+
*`method`: El valor de un string ya sea `'get'`o`'post'`. Este representa si el `<form>`se está enviando con el [método HTTP](https://developer.mozilla.org/es/docs/Web/HTTP/Methods)`GET` o `POST`. Por defecto, un`<form>`va a usar el método `GET`y puede estar especificado con la propiedad de [`method`](https://developer.mozilla.org/es/docs/Web/HTML/Element/form#method).
69
69
70
70
[//]: #(Link to `<form>` documentation. "Read more on the `action` prop on `<form>`.")
71
-
*`action`: A reference to the function passed to the `action` prop on the parent `<form>`. If there is no parent `<form>`, the property is`null`. If there is a URI value provided to the `action` prop, or no `action`prop specified, `status.action`will be `null`.
71
+
*`action`: Una referencia a la función que es pasada al prop de `action` en el `<form>` padre. Si no hay un `<form>` padre, la propiedad es`null`. Si se ha proporcionado un valor URI al prop de `action`, o no se ha especificado un prop de `action`, `status.action`va a ser `null`.
72
72
73
-
#### Caveats {/*caveats*/}
73
+
#### Advertencias {/*caveats*/}
74
74
75
-
*The `useFormStatus`Hook must be called from a component that is rendered inside a`<form>`.
76
-
*`useFormStatus`will only return status information for a parent `<form>`. It will not return status information for any `<form>`rendered in that same component or children components.
75
+
*El Hook `useFormStatus`debe llamarse desde un componente que se renderiza dentro de un`<form>`.
76
+
*`useFormStatus`solo retornará información de estado para un `<form>` padre. No retornará información de estado a ningún `<form>`renderizado en ese mismo componente o componente hijos.
77
77
78
78
---
79
79
80
-
## Usage {/*usage*/}
80
+
## Uso {/*usage*/}
81
81
82
-
### Display a pending state during form submission {/*display-a-pending-state-during-form-submission*/}
83
-
To display a pending state while a form is submitting, you can call the`useFormStatus`Hook in a component rendered in a `<form>`and read the `pending`property returned.
82
+
### Muestra un estado pendiente durante el envío de un formulario {/*display-a-pending-state-during-form-submission*/}
83
+
Para mostrar un estado pendiente mientras un formulario se está enviando, puedes llamar al Hook`useFormStatus`en un componente renderizado en un `<form>`y leer la propiedad `pending`que retorna.
84
84
85
-
Here, we use the`pending`property to indicate the form is submitting.
85
+
Aquí, usamos la propiedad`pending`para indicar que el formulario se está enviando.
86
86
87
87
<Sandpack>
88
88
@@ -94,7 +94,7 @@ function Submit() {
94
94
const { pending } =useFormStatus();
95
95
return (
96
96
<button type="submit" disabled={pending}>
97
-
{pending ?"Submitting...":"Submit"}
97
+
{pending ?"Enviando...":"Enviar"}
98
98
</button>
99
99
);
100
100
}
@@ -133,30 +133,30 @@ export async function submitForm(query) {
133
133
134
134
<Pitfall>
135
135
136
-
##### `useFormStatus`will not return status information for a `<form>`rendered in the same component. {/*useformstatus-will-not-return-status-information-for-a-form-rendered-in-the-same-component*/}
136
+
##### `useFormStatus`no retorna información de estado a un `<form>`renderizado en el mismo componente. {/*useformstatus-will-not-return-status-information-for-a-form-rendered-in-the-same-component*/}
137
137
138
-
The `useFormStatus`Hook only returns status information for a parent`<form>`and not for any `<form>`rendered in the same component calling the Hook, or child components.
138
+
El Hook `useFormStatus`solo retorna información de estado a un`<form>`padre y no para ningún `<form>`renderizado en el mismo componente que llama el Hook, o componentes hijos.
139
139
140
140
```js
141
141
functionForm() {
142
-
// 🚩 `pending` will never be true
143
-
// useFormStatus does not track the form rendered in this component
142
+
// 🚩 `pending` nunca será true
143
+
// useFormStatus no rastrea el formulario renderizado en este componente
144
144
const { pending } =useFormStatus();
145
145
return<form action={submit}></form>;
146
146
}
147
147
```
148
148
149
-
Instead call `useFormStatus`from inside a component that is located inside`<form>`.
149
+
En su lugar llama a `useFormStatus`desde dentro de un componente que se encuentra dentro de un`<form>`.
150
150
151
151
```js
152
152
functionSubmit() {
153
-
// ✅ `pending` will be derived from the form that wraps the Submit component
153
+
// ✅ `pending` se derivará del formulario que envuelve el componente Enviar
154
154
const { pending } =useFormStatus();
155
155
return<button disabled={pending}>...</button>;
156
156
}
157
157
158
158
functionForm() {
159
-
//This is the <form> `useFormStatus` tracks
159
+
//Este es el <form> que `useFormStatus` rastrea
160
160
return (
161
161
<form action={submit}>
162
162
<Submit />
@@ -167,11 +167,11 @@ function Form() {
167
167
168
168
</Pitfall>
169
169
170
-
### Read the form data being submitted {/*read-form-data-being-submitted*/}
170
+
### Lee los datos del formulario que se envían {/*read-form-data-being-submitted*/}
171
171
172
-
You can use the`data`property of the status information returned from `useFormStatus`to display what data is being submitted by the user.
172
+
Puedes usar la propiedad`data`de la información de estado que retorna del `useFormStatus`para mostrar qué datos está siendo enviando por el usuario.
173
173
174
-
Here, we have a form where users can request a username. We can use `useFormStatus`to display a temporary status message confirming what username they have requested.
174
+
Aquí, tenemos un formulario donde los usuarios pueden solicitar un nombre de usuario. Podemos usar `useFormStatus`para mostrar temporalmente un mensaje de estado que confirme qué nombre de usuario han solicitado.
175
175
176
176
<Sandpack>
177
177
@@ -184,13 +184,13 @@ export default function UsernameForm() {
`useFormStatus`will only return status information for a parent`<form>`.
256
+
`useFormStatus`solo retornará información de estado a un`<form>` padre.
257
257
258
-
If the component that calls `useFormStatus`is not nested in a`<form>`, `status.pending`will always return`false`. Verify`useFormStatus`is called in a component that is a child of a `<form>` element.
258
+
Si el componente que llama a `useFormStatus`no está anidado en un`<form>`, `status.pending`siempre retornará `false`. Verifica que `useFormStatus`está siendo llamado en un componente que es hijo de un elemento `<form>`.
259
259
260
-
`useFormStatus`will not track the status of a `<form>`rendered in the same component. See [Pitfall](#useformstatus-will-not-return-status-information-for-a-form-rendered-in-the-same-component) for more details.
260
+
`useFormStatus`no rastreará al estado de un `<form>`renderizado en el mismo componente. Mira [Atención](#useformstatus-will-not-return-status-information-for-a-form-rendered-in-the-same-component) para más detalles.
0 commit comments