Skip to content

Commit c186aab

Browse files
Translate lazy.md to pt-br (#915)
1 parent 6c2ba10 commit c186aab

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

src/content/reference/react/lazy.md

+33-33
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: lazy
44

55
<Intro>
66

7-
`lazy` lets you defer loading component's code until it is rendered for the first time.
7+
`lazy` permite que você adie o carregamento do código do componente até que ele seja renderizado pela primeira vez.
88

99
```js
1010
const SomeComponent = lazy(load)
@@ -16,63 +16,63 @@ const SomeComponent = lazy(load)
1616

1717
---
1818

19-
## Reference {/*reference*/}
19+
## Referência {/*reference*/}
2020

2121
### `lazy(load)` {/*lazy*/}
2222

23-
Call `lazy` outside your components to declare a lazy-loaded React component:
23+
Chame `lazy` fora dos seus componentes para declarar um componente React carregado de forma preguiçosa:
2424

2525
```js
2626
import { lazy } from 'react';
2727

2828
const MarkdownPreview = lazy(() => import('./MarkdownPreview.js'));
2929
```
3030

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

33-
#### Parameters {/*parameters*/}
33+
#### Parâmetros {/*parameters*/}
3434

35-
* `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.
3636

37-
#### Returns {/*returns*/}
37+
#### Retornos {/*returns*/}
3838

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.
4040

4141
---
4242

43-
### `load` function {/*load*/}
43+
### Função `load` {/*load*/}
4444

45-
#### Parameters {/*load-parameters*/}
45+
#### Parâmetros {/*load-parameters*/}
4646

47-
`load` receives no parameters.
47+
`load` não recebe parâmetros.
4848

49-
#### Returns {/*load-returns*/}
49+
#### Retornos {/*load-returns*/}
5050

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).
5252

5353
---
5454

55-
## Usage {/*usage*/}
55+
## Uso {/*usage*/}
5656

57-
### Lazy-loading components with Suspense {/*suspense-for-code-splitting*/}
57+
### Carregamento preguiçoso de componentes com Suspense {/*suspense-for-code-splitting*/}
5858

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):
6060

6161
```js
6262
import MarkdownPreview from './MarkdownPreview.js';
6363
```
6464

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:
6666

6767
```js
6868
import { lazy } from 'react';
6969

7070
const MarkdownPreview = lazy(() => import('./MarkdownPreview.js'));
7171
```
7272

73-
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`.
7474

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):
7676

7777
```js {1,4}
7878
<Suspense fallback={<Loading />}>
@@ -81,7 +81,7 @@ Now that your component's code loads on demand, you also need to specify what sh
8181
</Suspense>
8282
```
8383

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:
8585

8686
<Sandpack>
8787

@@ -99,20 +99,20 @@ export default function MarkdownEditor() {
9999
<textarea value={markdown} onChange={e => setMarkdown(e.target.value)} />
100100
<label>
101101
<input type="checkbox" checked={showPreview} onChange={e => setShowPreview(e.target.checked)} />
102-
Show preview
102+
Mostrar prévia
103103
</label>
104104
<hr />
105105
{showPreview && (
106106
<Suspense fallback={<Loading />}>
107-
<h2>Preview</h2>
107+
<h2>Prévia</h2>
108108
<MarkdownPreview markdown={markdown} />
109109
</Suspense>
110110
)}
111111
</>
112112
);
113113
}
114114

115-
// 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
116116
function delayForDemo(promise) {
117117
return new Promise(resolve => {
118118
setTimeout(resolve, 2000);
@@ -122,7 +122,7 @@ function delayForDemo(promise) {
122122

123123
```js src/Loading.js
124124
export default function Loading() {
125-
return <p><i>Loading...</i></p>;
125+
return <p><i>Carregando...</i></p>;
126126
}
127127
```
128128

@@ -175,37 +175,37 @@ body {
175175

176176
</Sandpack>
177177

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.
179179

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)
181181

182182
---
183183

184-
## Troubleshooting {/*troubleshooting*/}
184+
## Solução de Problemas {/*troubleshooting*/}
185185

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*/}
187187

188-
Do not declare `lazy` components *inside* other components:
188+
Não declare componentes `lazy` *dentro* de outros componentes:
189189

190190
```js {4-5}
191191
import { lazy } from 'react';
192192

193193
function Editor() {
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
195195
const MarkdownPreview = lazy(() => import('./MarkdownPreview.js'));
196196
// ...
197197
}
198198
```
199199

200-
Instead, always declare them at the top level of your module:
200+
Em vez disso, sempre declare-os no nível superior do seu módulo:
201201

202202
```js {3-4}
203203
import { lazy } from 'react';
204204

205-
//Good: Declare lazy components outside of your components
205+
//Bom: Declare componentes preguiçosos fora dos seus componentes
206206
const MarkdownPreview = lazy(() => import('./MarkdownPreview.js'));
207207

208208
function Editor() {
209209
// ...
210210
}
211-
```
211+
```

0 commit comments

Comments
 (0)