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
*`load`: A function that returns a[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)or another*thenable* (a Promise-like object with a`then` method). React will not call `load`until the first time you attempt to render the returned component. After React first calls `load`, it will wait for it to resolve, and then render the resolved value's `.default` as a React component. Both the returned Promise and the Promise's resolved value will be cached, so React will not call `load`more than once. If the Promise rejects, React will`throw`the rejection reason for the nearest Error Boundary to handle.
35
+
*`load`: Uma função que retorna uma[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)ou outro*thenable* (um objeto semelhante a uma Promise com um método`then`). O React não chamará `load`até a primeira vez que você tentar renderizar o componente retornado. Depois que o React chama `load` pela primeira vez, ele aguardará a resolução e, em seguida, renderizará o valor resolvido como um componente React. Tanto a Promise retornada quanto o valor resolvido da Promise serão armazenados em cache, de modo que o React não chamará `load`mais de uma vez. Se a Promise for rejeitada, o React irá`throw`a razão da rejeição para o mais próximo Error Boundary manipular.
36
36
37
-
#### Returns {/*returns*/}
37
+
#### Retornos {/*returns*/}
38
38
39
-
`lazy`returns a React component you can render in your tree. While the code for the lazy component is still loading, attempting to render it will *suspend.* Use [`<Suspense>`](/reference/react/Suspense)to display a loading indicator while it's loading.
39
+
`lazy`retorna um componente React que você pode renderizar em sua árvore. Enquanto o código do componente preguiçoso ainda estiver carregando, tentar renderizá-lo irá *suspender.* Use [`<Suspense>`](/reference/react/Suspense)para exibir um indicador de carregamento enquanto ele está carregando.
40
40
41
41
---
42
42
43
-
### `load` function {/*load*/}
43
+
### Função `load` {/*load*/}
44
44
45
-
#### Parameters {/*load-parameters*/}
45
+
#### Parâmetros {/*load-parameters*/}
46
46
47
-
`load`receives no parameters.
47
+
`load`não recebe parâmetros.
48
48
49
-
#### Returns {/*load-returns*/}
49
+
#### Retornos {/*load-returns*/}
50
50
51
-
You need to return a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)or some other*thenable* (a Promise-like object with a`then` method). It needs to eventually resolve to an object whose`.default`property is a valid React component type, such as a function, [`memo`](/reference/react/memo), or a [`forwardRef`](/reference/react/forwardRef) component.
51
+
Você precisa retornar uma [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)ou algum outro*thenable* (um objeto semelhante a uma Promise com um método`then`). Ele precisa eventualmente resolver para um objeto cuja propriedade`.default`é um tipo de componente React válido, como uma função, [`memo`](/reference/react/memo), ou um componente [`forwardRef`](/reference/react/forwardRef).
52
52
53
53
---
54
54
55
-
## Usage {/*usage*/}
55
+
## Uso {/*usage*/}
56
56
57
-
### Lazy-loading components with Suspense {/*suspense-for-code-splitting*/}
57
+
### Carregamento preguiçoso de componentes com Suspense {/*suspense-for-code-splitting*/}
58
58
59
-
Usually, you import components with the static [`import`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import) declaration:
59
+
Geralmente, você importa componentes com a declaração estática [`import`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import):
60
60
61
61
```js
62
62
importMarkdownPreviewfrom'./MarkdownPreview.js';
63
63
```
64
64
65
-
To defer loading this component's code until it's rendered for the first time, replace this import with:
65
+
Para adiar o carregamento do código desse componente até que ele seja renderizado pela primeira vez, substitua essa importação por:
This code relies on [dynamic `import()`,](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import)which might require support from your bundler or framework. Using this pattern requires that the lazy component you're importing was exported as the `default` export.
73
+
Este código depende do [import() dinâmico,](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import)que pode exigir suporte do seu bundler ou framework. Usar este padrão exige que o componente preguiçoso que você está importando tenha sido exportado como a exportação `default`.
74
74
75
-
Now that your component's code loads on demand, you also need to specify what should be displayed while it is loading. You can do this by wrapping the lazy component or any of its parents into a [`<Suspense>`](/reference/react/Suspense) boundary:
75
+
Agora que o código do seu componente é carregado sob demanda, você também precisa especificar o que deve ser exibido enquanto ele está carregando. Você pode fazer isso encapsulando o componente preguiçoso ou qualquer um de seus pais em um limite [`<Suspense>`](/reference/react/Suspense):
76
76
77
77
```js {1,4}
78
78
<Suspense fallback={<Loading />}>
@@ -81,7 +81,7 @@ Now that your component's code loads on demand, you also need to specify what sh
81
81
</Suspense>
82
82
```
83
83
84
-
In this example, the code for`MarkdownPreview`won't be loaded until you attempt to render it. If`MarkdownPreview`hasn't loaded yet, `Loading`will be shown in its place. Try ticking the checkbox:
84
+
Neste exemplo, o código para`MarkdownPreview`não será carregado até que você tente renderizá-lo. Se`MarkdownPreview`ainda não tiver carregado, `Loading`será exibido em seu lugar. Tente marcar a caixa de seleção:
85
85
86
86
<Sandpack>
87
87
@@ -99,20 +99,20 @@ export default function MarkdownEditor() {
//Add a fixed delay so you can see the loading state
115
+
//Adicione um atraso fixo para que você possa ver o estado de carregamento
116
116
functiondelayForDemo(promise) {
117
117
returnnewPromise(resolve=> {
118
118
setTimeout(resolve, 2000);
@@ -122,7 +122,7 @@ function delayForDemo(promise) {
122
122
123
123
```js src/Loading.js
124
124
exportdefaultfunctionLoading() {
125
-
return<p><i>Loading...</i></p>;
125
+
return<p><i>Carregando...</i></p>;
126
126
}
127
127
```
128
128
@@ -175,37 +175,37 @@ body {
175
175
176
176
</Sandpack>
177
177
178
-
This demo loads with an artificial delay. The next time you untick and tick the checkbox, `Preview` will be cached, so there will be no loading state. To see the loading state again, click "Reset" on the sandbox.
178
+
Esta demonstração carrega com um atraso artificial. Da próxima vez que você desmarcar e marcar a caixa de seleção, `Prévia` será armazenado em cache, então não haverá estado de carregamento. Para ver o estado de carregamento novamente, clique em "Redefinir" no sandbox.
179
179
180
-
[Learn more about managing loading states with Suspense.](/reference/react/Suspense)
180
+
[Saiba mais sobre como gerenciar estados de carregamento com Suspense.](/reference/react/Suspense)
181
181
182
182
---
183
183
184
-
## Troubleshooting {/*troubleshooting*/}
184
+
## Solução de Problemas {/*troubleshooting*/}
185
185
186
-
### My `lazy`component's state gets reset unexpectedly {/*my-lazy-components-state-gets-reset-unexpectedly*/}
186
+
### O estado do meu componente `lazy`é redefinido inesperadamente {/*my-lazy-components-state-gets-reset-unexpectedly*/}
187
187
188
-
Do not declare `lazy`components *inside* other components:
188
+
Não declare componentes `lazy`*dentro* de outros componentes:
189
189
190
190
```js {4-5}
191
191
import { lazy } from'react';
192
192
193
193
functionEditor() {
194
-
// 🔴 Bad: This will cause all state to be reset on re-renders
194
+
// 🔴 Ruim: Isso fará com que todo o estado seja redefinido em novas renderizações
0 commit comments