Skip to content

Commit 6859184

Browse files
Translate form.md to Portuguese (#1016)
1 parent aa60a25 commit 6859184

File tree

1 file changed

+39
-39
lines changed
  • src/content/reference/react-dom/components

1 file changed

+39
-39
lines changed

src/content/reference/react-dom/components/form.md

+39-39
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: "<form>"
44

55
<Intro>
66

7-
The [built-in browser `<form>` component](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) lets you create interactive controls for submitting information.
7+
O [componente `<form>` do navegador embutido](https://developer.mozilla.org/pt-BR/docs/Web/HTML/Element/form) permite que você crie controles interativos para enviar informações.
88

99
```js
1010
<form action={search}>
@@ -19,11 +19,11 @@ The [built-in browser `<form>` component](https://developer.mozilla.org/en-US/do
1919

2020
---
2121

22-
## Reference {/*reference*/}
22+
## Referência {/*reference*/}
2323

2424
### `<form>` {/*form*/}
2525

26-
To create interactive controls for submitting information, render the [built-in browser `<form>` component](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form).
26+
Para criar controles interativos para enviar informações, renderize o [componente `<form>` do navegador embutido](https://developer.mozilla.org/pt-BR/docs/Web/HTML/Element/form).
2727

2828
```js
2929
<form action={search}>
@@ -32,25 +32,25 @@ To create interactive controls for submitting information, render the [built-in
3232
</form>
3333
```
3434

35-
[See more examples below.](#usage)
35+
[Veja mais exemplos abaixo.](#usage)
3636

3737
#### Props {/*props*/}
3838

39-
`<form>` supports all [common element props.](/reference/react-dom/components/common#props)
39+
`<form>` suporta todas as [props de elementos comuns.](/reference/react-dom/components/common#props)
4040

41-
[`action`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#action): a URL or function. When a URL is passed to `action` the form will behave like the HTML form component. When a function is passed to `action` the function will handle the form submission. The function passed to `action` may be async and will be called with a single argument containing the [form data](https://developer.mozilla.org/en-US/docs/Web/API/FormData) of the submitted form. The `action` prop can be overridden by a `formAction` attribute on a `<button>`, `<input type="submit">`, or `<input type="image">` component.
41+
[`action`](https://developer.mozilla.org/pt-BR/docs/Web/HTML/Element/form#action): uma URL ou função. Quando uma URL é passada para `action`, o formulário se comportará como o componente de formulário HTML. Quando uma função é passada para `action`, a função irá manipular o envio do formulário. A função passada para `action` pode ser async e será chamada com um único argumento contendo os [dados do formulário](https://developer.mozilla.org/pt-BR/docs/Web/API/FormData) do formulário enviado. A prop `action` pode ser substituída por um atributo `formAction` em um componente `<button>`, `<input type="submit">` ou `<input type="image">`.
4242

43-
#### Caveats {/*caveats*/}
43+
#### Ressalvas {/*caveats*/}
4444

45-
* When a function is passed to `action` or `formAction` the HTTP method will be POST regardless of value of the `method` prop.
45+
* Quando uma função é passada para `action` ou `formAction`, o método HTTP será POST, independentemente do valor da prop `method`.
4646

4747
---
4848

49-
## Usage {/*usage*/}
49+
## Uso {/*usage*/}
5050

51-
### Handle form submission on the client {/*handle-form-submission-on-the-client*/}
51+
### Manipular envio de formulário no cliente {/*handle-form-submission-on-the-client*/}
5252

53-
Pass a function to the `action` prop of form to run the function when the form is submitted. [`formData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) will be passed to the function as an argument so you can access the data submitted by the form. This differs from the conventional [HTML action](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#action), which only accepts URLs. After the `action` function succeeds, all uncontrolled field elements in the form are reset.
53+
Passe uma função para a prop `action` do formulário para executar a função quando o formulário for enviado. [`formData`](https://developer.mozilla.org/pt-BR/docs/Web/API/FormData) será passado para a função como um argumento para que você possa acessar os dados enviados pelo formulário. Isso difere da [ação HTML](https://developer.mozilla.org/pt-BR/docs/Web/HTML/Element/form#action) convencional, que aceita apenas URLs. Após a execução da função `action`, todos os elementos de campo não controlados no formulário são redefinidos.
5454

5555
<Sandpack>
5656

@@ -71,13 +71,13 @@ export default function Search() {
7171

7272
</Sandpack>
7373

74-
### Handle form submission with a Server Function {/*handle-form-submission-with-a-server-function*/}
74+
### Manipular envio de formulário com uma Server Function {/*handle-form-submission-with-a-server-function*/}
7575

76-
Render a `<form>` with an input and submit button. Pass a Server Function (a function marked with [`'use server'`](/reference/rsc/use-server)) to the `action` prop of form to run the function when the form is submitted.
76+
Renderize um `<form>` com um input e um botão de envio. Passe uma Server Function (uma função marcada com [`'use server'`](/reference/rsc/use-server)) para a prop `action` do formulário para executar a função quando o formulário for enviado.
7777

78-
Passing a Server Function to `<form action>` allow users to submit forms without JavaScript enabled or before the code has loaded. This is beneficial to users who have a slow connection, device, or have JavaScript disabled and is similar to the way forms work when a URL is passed to the `action` prop.
78+
Passar uma Server Function para `<form action>` permite que os usuários enviem formulários sem o JavaScript ativado ou antes que o código seja carregado. Isso é benéfico para usuários que têm uma conexão lenta, dispositivo ou têm o JavaScript desativado e é semelhante à maneira como os formulários funcionam quando uma URL é passada para a prop `action`.
7979

80-
You can use hidden form fields to provide data to the `<form>`'s action. The Server Function will be called with the hidden form field data as an instance of [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData).
80+
Você pode usar campos de formulário ocultos para fornecer dados para a ação do `<form>`. A Server Function será chamada com os dados do campo de formulário oculto como uma instância de [`FormData`](https://developer.mozilla.org/pt-BR/docs/Web/API/FormData).
8181

8282
```jsx
8383
import { updateCart } from './lib.js';
@@ -98,7 +98,7 @@ function AddToCart({productId}) {
9898
}
9999
```
100100

101-
In lieu of using hidden form fields to provide data to the `<form>`'s action, you can call the <CodeStep step={1}>`bind`</CodeStep> method to supply it with extra arguments. This will bind a new argument (<CodeStep step={2}>`productId`</CodeStep>) to the function in addition to the <CodeStep step={3}>`formData`</CodeStep> that is passed as an argument to the function.
101+
Em vez de usar campos de formulário ocultos para fornecer dados à ação do `<form>`, você pode chamar o método <CodeStep step={1}>`bind`</CodeStep> para fornecer argumentos extras. Isso vinculará um novo argumento (<CodeStep step={2}>`productId`</CodeStep>) à função, além do <CodeStep step={3}>`formData`</CodeStep> que é passado como argumento para a função.
102102

103103
```jsx [[1, 8, "bind"], [2,8, "productId"], [2,4, "productId"], [3,4, "formData"]]
104104
import { updateCart } from './lib.js';
@@ -117,12 +117,12 @@ function AddToCart({productId}) {
117117
}
118118
```
119119

120-
When `<form>` is rendered by a [Server Component](/reference/rsc/use-client), and a [Server Function](/reference/rsc/server-functions) is passed to the `<form>`'s `action` prop, the form is [progressively enhanced](https://developer.mozilla.org/en-US/docs/Glossary/Progressive_Enhancement).
120+
Quando o `<form>` é renderizado por um [Server Component](/reference/rsc/use-client), e uma [Server Function](/reference/rsc/server-functions) é passada para a prop `action` do `<form>`, o formulário é [progressivamente aprimorado](https://developer.mozilla.org/pt-BR/docs/Glossary/Progressive_Enhancement).
121121

122-
### Display a pending state during form submission {/*display-a-pending-state-during-form-submission*/}
123-
To display a pending state when a form is being submitted, you can call the `useFormStatus` Hook in a component rendered in a `<form>` and read the `pending` property returned.
122+
### Exibir um estado pendente durante o envio do formulário {/*display-a-pending-state-during-form-submission*/}
123+
Para exibir um estado pendente quando um formulário está sendo enviado, você pode chamar o Hook `useFormStatus` em um componente renderizado em um `<form>` e ler a propriedade `pending` retornada.
124124

125-
Here, we use the `pending` property to indicate the form is submitting.
125+
Aqui, usamos a propriedade `pending` para indicar que o formulário está sendo enviado.
126126

127127
<Sandpack>
128128

@@ -160,12 +160,12 @@ export async function submitForm(query) {
160160

161161
</Sandpack>
162162

163-
To learn more about the `useFormStatus` Hook see the [reference documentation](/reference/react-dom/hooks/useFormStatus).
163+
Para saber mais sobre o Hook `useFormStatus`, consulte a [documentação de referência](/reference/react-dom/hooks/useFormStatus).
164164

165-
### Optimistically updating form data {/*optimistically-updating-form-data*/}
166-
The `useOptimistic` Hook provides a way to optimistically update the user interface before a background operation, like a network request, completes. In the context of forms, this technique helps to make apps feel more responsive. When a user submits a form, instead of waiting for the server's response to reflect the changes, the interface is immediately updated with the expected outcome.
165+
### Atualizando otimistamente dados do formulário {/*optimistically-updating-form-data*/}
166+
O Hook `useOptimistic` fornece uma maneira de atualizar otimistamente a interface do usuário antes que uma operação em segundo plano, como uma solicitação de rede, seja concluída. No contexto de formulários, essa técnica ajuda a tornar os aplicativos mais responsivos. Quando um usuário envia um formulário, em vez de esperar pela resposta do servidor para refletir as alterações, a interface é imediatamente atualizada com o resultado esperado.
167167

168-
For example, when a user types a message into the form and hits the "Send" button, the `useOptimistic` Hook allows the message to immediately appear in the list with a "Sending..." label, even before the message is actually sent to a server. This "optimistic" approach gives the impression of speed and responsiveness. The form then attempts to truly send the message in the background. Once the server confirms the message has been received, the "Sending..." label is removed.
168+
Por exemplo, quando um usuário digita uma mensagem no formulário e pressiona o botão "Enviar", o Hook `useOptimistic` permite que a mensagem apareça imediatamente na lista com um rótulo "Enviando...", mesmo antes que a mensagem seja realmente enviada para um servidor. Essa abordagem "otimista" dá a impressão de velocidade e responsividade. O formulário então tenta enviar a mensagem de verdade em segundo plano. Depois que o servidor confirma que a mensagem foi recebida, o rótulo "Enviando..." é removido.
169169

170170
<Sandpack>
171171

@@ -229,12 +229,12 @@ export async function deliverMessage(message) {
229229

230230
</Sandpack>
231231

232-
[//]: # 'Uncomment the next line, and delete this line after the `useOptimistic` reference documentatino page is published'
233-
[//]: # 'To learn more about the `useOptimistic` Hook see the [reference documentation](/reference/react/hooks/useOptimistic).'
232+
[//]: # 'Remova o comentário da próxima linha e exclua esta linha após a publicação da página de documentação de referência `useOptimistic`'
233+
[//]: # 'Para saber mais sobre o Hook `useOptimistic`, consulte a [documentação de referência](/reference/react/hooks/useOptimistic).'
234234

235-
### Handling form submission errors {/*handling-form-submission-errors*/}
235+
### Lidando com erros de envio de formulário {/*handling-form-submission-errors*/}
236236

237-
In some cases the function called by a `<form>`'s `action` prop throws an error. You can handle these errors by wrapping `<form>` in an Error Boundary. If the function called by a `<form>`'s `action` prop throws an error, the fallback for the error boundary will be displayed.
237+
Em alguns casos, a função chamada pela prop `action` de um `<form>` lança um erro. Você pode tratar esses erros envolvendo o `<form>` em um Error Boundary. Se a função chamada pela prop `action` de um `<form>` lançar um erro, o fallback para o error boundary será exibido.
238238

239239
<Sandpack>
240240

@@ -274,15 +274,15 @@ export default function Search() {
274274

275275
</Sandpack>
276276

277-
### Display a form submission error without JavaScript {/*display-a-form-submission-error-without-javascript*/}
277+
### Exibir um erro de envio de formulário sem JavaScript {/*display-a-form-submission-error-without-javascript*/}
278278

279-
Displaying a form submission error message before the JavaScript bundle loads for progressive enhancement requires that:
279+
Exibir uma mensagem de erro de envio de formulário antes que o bundle JavaScript seja carregado para aprimoramento progressivo exige que:
280280

281-
1. `<form>` be rendered by a [Server Component](/reference/rsc/use-client)
282-
1. the function passed to the `<form>`'s `action` prop be a [Server Function](/reference/rsc/server-functions)
283-
1. the `useActionState` Hook be used to display the error message
281+
1. `<form>` seja renderizado por um [Server Component](/reference/rsc/use-client)
282+
1. a função passada para a prop `action` do `<form>` seja uma [Server Function](/reference/rsc/server-functions)
283+
1. o Hook `useActionState` seja usado para exibir a mensagem de erro
284284

285-
`useActionState` takes two parameters: a [Server Function](/reference/rsc/server-functions) and an initial state. `useActionState` returns two values, a state variable and an action. The action returned by `useActionState` should be passed to the `action` prop of the form. The state variable returned by `useActionState` can be used to display an error message. The value returned by the Server Function passed to `useActionState` will be used to update the state variable.
285+
`useActionState` recebe dois parâmetros: um [Server Function](/reference/rsc/server-functions) e um estado inicial. `useActionState` retorna dois valores, uma variável de estado e uma ação. A ação retornada por `useActionState` deve ser passada para a prop `action` do formulário. A variável de estado retornada por `useActionState` pode ser usada para exibir uma mensagem de erro. O valor retornado pela Server Function passada para `useActionState` será usado para atualizar a variável de estado.
286286

287287
<Sandpack>
288288

@@ -330,13 +330,13 @@ export async function signUpNewUser(newEmail) {
330330

331331
</Sandpack>
332332

333-
Learn more about updating state from a form action with the [`useActionState`](/reference/react/useActionState) docs
333+
Saiba mais sobre como atualizar o estado de uma ação de formulário com a documentação [`useActionState`](/reference/react/useActionState)
334334

335-
### Handling multiple submission types {/*handling-multiple-submission-types*/}
335+
### Lidar com vários tipos de envio {/*handling-multiple-submission-types*/}
336336

337-
Forms can be designed to handle multiple submission actions based on the button pressed by the user. Each button inside a form can be associated with a distinct action or behavior by setting the `formAction` prop.
337+
Os formulários podem ser projetados para lidar com várias ações de envio com base no botão pressionado pelo usuário. Cada botão dentro de um formulário pode ser associado a uma ação ou comportamento distinto definindo a prop `formAction`.
338338

339-
When a user taps a specific button, the form is submitted, and a corresponding action, defined by that button's attributes and action, is executed. For instance, a form might submit an article for review by default but have a separate button with `formAction` set to save the article as a draft.
339+
Quando um usuário toca em um botão específico, o formulário é enviado e uma ação correspondente, definida pelos atributos e ação daquele botão, é executada. Por exemplo, um formulário pode, por padrão, enviar um artigo para revisão, mas ter um botão separado com o `formAction` definido para salvar o artigo como um rascunho.
340340

341341
<Sandpack>
342342

@@ -364,4 +364,4 @@ export default function Search() {
364364
}
365365
```
366366

367-
</Sandpack>
367+
</Sandpack>

0 commit comments

Comments
 (0)