Skip to content

Commit 30e703e

Browse files
Translate flushSync.md to Portuguese (#1024)
1 parent 164020d commit 30e703e

File tree

1 file changed

+28
-29
lines changed

1 file changed

+28
-29
lines changed

src/content/reference/react-dom/flushSync.md

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ title: flushSync
44

55
<Pitfall>
66

7-
Using `flushSync` is uncommon and can hurt the performance of your app.
7+
Usar `flushSync` é incomum e pode prejudicar a performance do seu app.
88

99
</Pitfall>
1010

1111
<Intro>
1212

13-
`flushSync` lets you force React to flush any updates inside the provided callback synchronously. This ensures that the DOM is updated immediately.
13+
`flushSync` permite que você force o React a descarregar quaisquer atualizações dentro do callback fornecido de forma síncrona. Isso garante que o DOM seja atualizado imediatamente.
1414

1515
```js
1616
flushSync(callback)
@@ -22,11 +22,11 @@ flushSync(callback)
2222

2323
---
2424

25-
## Reference {/*reference*/}
25+
## Referência {/*reference*/}
2626

2727
### `flushSync(callback)` {/*flushsync*/}
2828

29-
Call `flushSync` to force React to flush any pending work and update the DOM synchronously.
29+
Chame `flushSync` para forçar o React a finalizar qualquer trabalho pendente e atualizar o DOM de forma síncrona.
3030

3131
```js
3232
import { flushSync } from 'react-dom';
@@ -36,50 +36,49 @@ flushSync(() => {
3636
});
3737
```
3838

39-
Most of the time, `flushSync` can be avoided. Use `flushSync` as last resort.
39+
Na maior parte do tempo, `flushSync` pode ser evitado. Use `flushSync` como último recurso.
4040

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

43-
#### Parameters {/*parameters*/}
43+
#### Parâmetros {/*parameters*/}
4444

45+
* `callback`: Uma função. O React chamará imediatamente este callback e descarregará todas as atualizações que ele contém de forma síncrona. Ele também pode descarregar quaisquer atualizações pendentes, ou `Effects`, ou atualizações dentro de `Effects`. Se uma atualização suspender como resultado desta chamada `flushSync`, os fallbacks podem ser exibidos novamente.
4546

46-
* `callback`: A function. React will immediately call this callback and flush any updates it contains synchronously. It may also flush any pending updates, or Effects, or updates inside of Effects. If an update suspends as a result of this `flushSync` call, the fallbacks may be re-shown.
47+
#### Retorna {/*returns*/}
4748

48-
#### Returns {/*returns*/}
49+
`flushSync` retorna `undefined`.
4950

50-
`flushSync` returns `undefined`.
51+
#### Ressalvas {/*caveats*/}
5152

52-
#### Caveats {/*caveats*/}
53-
54-
* `flushSync` can significantly hurt performance. Use sparingly.
55-
* `flushSync` may force pending Suspense boundaries to show their `fallback` state.
56-
* `flushSync` may run pending Effects and synchronously apply any updates they contain before returning.
57-
* `flushSync` may flush updates outside the callback when necessary to flush the updates inside the callback. For example, if there are pending updates from a click, React may flush those before flushing the updates inside the callback.
53+
* `flushSync` pode prejudicar significativamente a performance. Use com moderação.
54+
* `flushSync` pode forçar limites pendentes de Suspense a mostrar seu estado de `fallback`.
55+
* `flushSync` pode executar `Effects` pendentes e aplicar de forma síncrona quaisquer atualizações que eles contenham antes de retornar.
56+
* `flushSync` pode descarregar atualizações fora do callback quando necessário para descarregar as atualizações dentro do callback. Por exemplo, se houver atualizações pendentes de um clique, o React pode descarregá-las antes de descarregar as atualizações dentro do callback.
5857

5958
---
6059

61-
## Usage {/*usage*/}
60+
## Uso {/*usage*/}
6261

63-
### Flushing updates for third-party integrations {/*flushing-updates-for-third-party-integrations*/}
62+
### Descarregando atualizações para integrações de terceiros {/*flushing-updates-for-third-party-integrations*/}
6463

65-
When integrating with third-party code such as browser APIs or UI libraries, it may be necessary to force React to flush updates. Use `flushSync` to force React to flush any <CodeStep step={1}>state updates</CodeStep> inside the callback synchronously:
64+
Ao integrar com código de terceiros, como APIs de navegador ou bibliotecas de UI, pode ser necessário forçar o React a finalizar as atualizações. Use `flushSync` para forçar o React a descarregar quaisquer <CodeStep step={1}>atualizações de state</CodeStep> dentro do callback de forma síncrona:
6665

6766
```js [[1, 2, "setSomething(123)"]]
6867
flushSync(() => {
6968
setSomething(123);
7069
});
71-
// By this line, the DOM is updated.
70+
// Por esta linha, o DOM é atualizado.
7271
```
7372

74-
This ensures that, by the time the next line of code runs, React has already updated the DOM.
73+
Isso garante que, quando a próxima linha de código for executada, o React já tenha atualizado o DOM.
7574

76-
**Using `flushSync` is uncommon, and using it often can significantly hurt the performance of your app.** If your app only uses React APIs, and does not integrate with third-party libraries, `flushSync` should be unnecessary.
75+
**Usar `flushSync` é incomum, e usá-lo com frequência pode prejudicar significativamente a performance do seu app.** Se o seu app usa apenas as APIs do React, e não se integra com bibliotecas de terceiros, `flushSync` deve ser desnecessário.
7776

78-
However, it can be helpful for integrating with third-party code like browser APIs.
77+
No entanto, pode ser útil para integrar com código de terceiros, como APIs de navegador.
7978

80-
Some browser APIs expect results inside of callbacks to be written to the DOM synchronously, by the end of the callback, so the browser can do something with the rendered DOM. In most cases, React handles this for you automatically. But in some cases it may be necessary to force a synchronous update.
79+
Algumas APIs de navegador esperam que os resultados dentro de callbacks sejam escritos para o DOM de forma síncrona, até o final do callback, para que o navegador possa fazer algo com o DOM renderizado. Na maioria dos casos, o React lida com isso automaticamente. Mas em alguns casos pode ser necessário forçar uma atualização síncrona.
8180

82-
For example, the browser `onbeforeprint` API allows you to change the page immediately before the print dialog opens. This is useful for applying custom print styles that allow the document to display better for printing. In the example below, you use `flushSync` inside of the `onbeforeprint` callback to immediately "flush" the React state to the DOM. Then, by the time the print dialog opens, `isPrinting` displays "yes":
81+
Por exemplo, a API `onbeforeprint` do navegador permite que você altere a página imediatamente antes da abertura da caixa de diálogo de impressão. Isso é útil para aplicar estilos de impressão personalizados que permitem que o documento seja exibido melhor para impressão. No exemplo abaixo, você usa `flushSync` dentro do callback `onbeforeprint` para "descarregar" imediatamente o estado do React para o DOM. Então, quando a caixa de diálogo de impressão for aberta, `isPrinting` exibirá "yes":
8382

8483
<Sandpack>
8584

@@ -122,12 +121,12 @@ export default function PrintApp() {
122121

123122
</Sandpack>
124123

125-
Without `flushSync`, the print dialog will display `isPrinting` as "no". This is because React batches the updates asynchronously and the print dialog is displayed before the state is updated.
124+
Sem `flushSync`, a caixa de diálogo de impressão exibirá `isPrinting` como "no". Isso ocorre porque o React agrupa as atualizações de forma assíncrona e a caixa de diálogo de impressão é exibida antes que o estado seja atualizado.
126125

127126
<Pitfall>
128127

129-
`flushSync` can significantly hurt performance, and may unexpectedly force pending Suspense boundaries to show their fallback state.
128+
`flushSync` pode prejudicar significativamente a performance e pode forçar inesperadamente limites pendentes de Suspense a mostrar seu estado de fallback.
130129

131-
Most of the time, `flushSync` can be avoided, so use `flushSync` as a last resort.
130+
Na maior parte do tempo, `flushSync` pode ser evitado, então use `flushSync` como último recurso.
132131

133-
</Pitfall>
132+
</Pitfall>

0 commit comments

Comments
 (0)