Skip to content

Commit ebb262f

Browse files
docs: translate cacheSignal.md to Português (Brasil) (#1239)
Co-authored-by: translate-react-bot[bot] <251169733+translate-react-bot[bot]@users.noreply.github.com>
1 parent c3643c6 commit ebb262f

1 file changed

Lines changed: 26 additions & 26 deletions

File tree

src/content/reference/react/cacheSignal.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ title: cacheSignal
44

55
<RSC>
66

7-
`cacheSignal` is currently only used with [React Server Components](/blog/2023/03/22/react-labs-what-we-have-been-working-on-march-2023#react-server-components).
7+
`cacheSignal` é atualmente usado apenas com [React Server Components](/blog/2023/03/22/react-labs-what-we-have-been-working-on-march-2023#react-server-components).
88

99
</RSC>
1010

1111
<Intro>
1212

13-
`cacheSignal` allows you to know when the `cache()` lifetime is over.
13+
`cacheSignal` permite que você saiba quando o tempo de vida do `cache()` terminou.
1414

1515
```js
1616
const signal = cacheSignal();
@@ -22,11 +22,11 @@ const signal = cacheSignal();
2222

2323
---
2424

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

2727
### `cacheSignal` {/*cachesignal*/}
2828

29-
Call `cacheSignal` to get an `AbortSignal`.
29+
Chame `cacheSignal` para obter um `AbortSignal`.
3030

3131
```js {3,7}
3232
import {cacheSignal} from 'react';
@@ -35,32 +35,32 @@ async function Component() {
3535
}
3636
```
3737

38-
When React has finished rendering, the `AbortSignal` will be aborted. This allows you to cancel any in-flight work that is no longer needed.
39-
Rendering is considered finished when:
40-
- React has successfully completed rendering
41-
- the render was aborted
42-
- the render has failed
38+
Quando o React terminar de renderizar, o `AbortSignal` será abortado. Isso permite que você cancele qualquer trabalho em andamento que não seja mais necessário.
39+
A renderização é considerada concluída quando:
40+
- O React concluiu a renderização com sucesso
41+
- a renderização foi abortada
42+
- a renderização falhou
4343

44-
#### Parameters {/*parameters*/}
44+
#### Parâmetros {/*parameters*/}
4545

46-
This function does not accept any parameters.
46+
Esta função não aceita parâmetros.
4747

48-
#### Returns {/*returns*/}
48+
#### Retorna {/*returns*/}
4949

50-
`cacheSignal` returns an `AbortSignal` if called during rendering. Otherwise `cacheSignal()` returns `null`.
50+
`cacheSignal` retorna um `AbortSignal` se chamado durante a renderização. Caso contrário, `cacheSignal()` retorna `null`.
5151

52-
#### Caveats {/*caveats*/}
52+
#### Ressalvas {/*caveats*/}
5353

54-
- `cacheSignal` is currently for use in [React Server Components](/reference/rsc/server-components) only. In Client Components, it will always return `null`. In the future it will also be used for Client Component when a client cache refreshes or invalidates. You should not assume it'll always be null on the client.
55-
- If called outside of rendering, `cacheSignal` will return `null` to make it clear that the current scope isn't cached forever.
54+
- `cacheSignal` é atualmente apenas para uso em [React Server Components](/reference/rsc/server-components). Em Client Components, ele sempre retornará `null`. No futuro, ele também será usado para Client Components quando um cache do cliente for atualizado ou invalidado. Você não deve assumir que ele sempre será nulo no cliente.
55+
- Se chamado fora da renderização, `cacheSignal` retornará `null` para deixar claro que o escopo atual não é cacheado para sempre.
5656

5757
---
5858

59-
## Usage {/*usage*/}
59+
## Uso {/*usage*/}
6060

61-
### Cancel in-flight requests {/*cancel-in-flight-requests*/}
61+
### Cancelar requisições em andamento {/*cancel-in-flight-requests*/}
6262

63-
Call <CodeStep step={1}>`cacheSignal`</CodeStep> to abort in-flight requests.
63+
Chame <CodeStep step={1}>`cacheSignal`</CodeStep> para abortar requisições em andamento.
6464

6565
```js [[1, 4, "cacheSignal()"]]
6666
import {cache, cacheSignal} from 'react';
@@ -71,21 +71,21 @@ async function Component() {
7171
```
7272

7373
<Pitfall>
74-
You can't use `cacheSignal` to abort async work that was started outside of rendering e.g.
74+
Você não pode usar `cacheSignal` para abortar trabalho assíncrono que foi iniciado fora da renderização, por exemplo:
7575

7676
```js
7777
import {cacheSignal} from 'react';
78-
// 🚩 Pitfall: The request will not actually be aborted if the rendering of `Component` is finished.
78+
// 🚩 Armadilha: A requisição não será realmente abortada se a renderização de `Component` for concluída.
7979
const response = fetch(url, { signal: cacheSignal() });
8080
async function Component() {
8181
await response;
8282
}
8383
```
8484
</Pitfall>
8585

86-
### Ignore errors after React has finished rendering {/*ignore-errors-after-react-has-finished-rendering*/}
86+
### Ignorar erros após o React ter terminado a renderização {/*ignore-errors-after-react-has-finished-rendering*/}
8787

88-
If a function throws, it may be due to cancellation (e.g. <CodeStep step={1}>the Database connection</CodeStep> has been closed). You can use the <CodeStep step={2}>`aborted` property</CodeStep> to check if the error was due to cancellation or a real error. You may want to <CodeStep step={3}>ignore errors</CodeStep> that were due to cancellation.
88+
Se uma função lançar um erro, pode ser devido a um cancelamento (por exemplo, a conexão do <CodeStep step={1}>Banco de Dados</CodeStep> foi fechada). Você pode usar a propriedade <CodeStep step={2}>`aborted`</CodeStep> para verificar se o erro foi devido a um cancelamento ou a um erro real. Você pode querer <CodeStep step={3}>ignorar erros</CodeStep> que foram devido a cancelamento.
8989

9090
```js [[1, 2, "./database"], [2, 8, "cacheSignal()?.aborted"], [3, 12, "return null"]]
9191
import {cacheSignal} from "react";
@@ -96,7 +96,7 @@ async function getData(id) {
9696
return await queryDatabase(id);
9797
} catch (x) {
9898
if (!cacheSignal()?.aborted) {
99-
// only log if it's a real error and not due to cancellation
99+
// apenas registre se for um erro real e não devido a cancelamento
100100
logError(x);
101101
}
102102
return null;
@@ -106,8 +106,8 @@ async function getData(id) {
106106
async function Component({id}) {
107107
const data = await getData(id);
108108
if (data === null) {
109-
return <div>No data available</div>;
109+
return <div>Nenhum dado disponível</div>;
110110
}
111111
return <div>{data.name}</div>;
112112
}
113-
```
113+
```

0 commit comments

Comments
 (0)