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
Copy file name to clipboardExpand all lines: src/content/reference/react-dom/preload.md
+40-40Lines changed: 40 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,13 +4,13 @@ title: preload
4
4
5
5
<Note>
6
6
7
-
[React-based frameworks](/learn/start-a-new-react-project)frequently handle resource loading for you, so you might not have to call this API yourself. Consult your framework's documentation for details.
7
+
[Frameworks baseados em React](/learn/start-a-new-react-project)frequentemente lidam com o carregamento de recursos para você, então você pode não precisar chamar esta API sozinho. Consulte a documentação de seu framework para obter detalhes.
8
8
9
9
</Note>
10
10
11
11
<Intro>
12
12
13
-
`preload`lets you eagerly fetch a resource such as a stylesheet, font, or external script that you expect to use.
13
+
`preload`permite que você busque antecipadamente um recurso como uma stylesheet, fonte, ou script externo que você espera usar.
To preload a resource, call the `preload`function from`react-dom`.
29
+
Para fazer o pré-carregamento (preload) de um recurso, chame a função `preload`de`react-dom`.
30
30
31
31
```js
32
32
import { preload } from'react-dom';
@@ -38,47 +38,47 @@ function AppRoot() {
38
38
39
39
```
40
40
41
-
[See more examples below.](#usage)
41
+
[Veja mais exemplos abaixo.](#usage)
42
42
43
-
The `preload`function provides the browser with a hint that it should start downloading the given resource, which can save time.
43
+
A função `preload`fornece ao navegador uma dica de que ele deve começar a baixar o recurso fornecido, o que pode economizar tempo.
44
44
45
-
#### Parameters {/*parameters*/}
45
+
#### Parâmetros {/*parameters*/}
46
46
47
-
*`href`: a string. The URL of the resource you want to download.
48
-
*`options`: an object. It contains the following properties:
49
-
*`as`: a required string. The type of resource. Its [possible values](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#as)are`audio`, `document`, `embed`, `fetch`, `font`, `image`, `object`, `script`, `style`, `track`, `video`, `worker`.
50
-
*`crossOrigin`: a string. The [CORS policy](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin)to use. Its possible values are`anonymous`and`use-credentials`. It is required when `as`is set to`"fetch"`.
51
-
*`referrerPolicy`: a string. The [Referrer header](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#referrerpolicy)to send when fetching. Its possible values are`no-referrer-when-downgrade` (the default), `no-referrer`, `origin`, `origin-when-cross-origin`, and`unsafe-url`.
52
-
*`integrity`: a string. A cryptographic hash of the resource, to [verify its authenticity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity).
53
-
*`type`: a string. The MIME type of the resource.
54
-
*`nonce`: a string. A cryptographic [nonce to allow the resource](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce)when using a strict Content Security Policy.
55
-
*`fetchPriority`: a string. Suggests a relative priority for fetching the resource. The possible values are`auto` (the default), `high`, and`low`.
56
-
*`imageSrcSet`: a string. For use only with`as: "image"`. Specifies the [source set of the image](https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images).
57
-
*`imageSizes`: a string. For use only with`as: "image"`. Specifies the [sizes of the image](https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images).
47
+
*`href`: uma string. A URL do recurso que você deseja baixar.
48
+
*`options`: um objeto. Ele contém as seguintes propriedades:
49
+
*`as`: uma string obrigatória. O tipo de recurso. Seus [valores possíveis](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#as)são`audio`, `document`, `embed`, `fetch`, `font`, `image`, `object`, `script`, `style`, `track`, `video`, `worker`.
50
+
*`crossOrigin`: uma string. A [política CORS](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin)a ser usada. Seus valores possíveis são`anonymous`e`use-credentials`. É obrigatório quando `as`é definido como`"fetch"`.
51
+
*`referrerPolicy`: uma string. O [cabeçalho Referrer](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#referrerpolicy)a ser enviado durante a busca. Seus valores possíveis são`no-referrer-when-downgrade` (o padrão), `no-referrer`, `origin`, `origin-when-cross-origin` e`unsafe-url`.
52
+
*`integrity`: uma string. Um hash criptográfico do recurso, para [verificar sua autenticidade](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity).
53
+
*`type`: uma string. O tipo MIME do recurso.
54
+
*`nonce`: uma string. Um [nonce](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce)criptográfico para permitir o recurso ao usar uma Content Security Policy estrita.
55
+
*`fetchPriority`: uma string. Sugere uma prioridade relativa para buscar o recurso. Os valores possíveis são`auto` (o padrão), `high` e`low`.
56
+
*`imageSrcSet`: uma string. Para uso somente com`as: "image"`. Especifica o [conjunto de origem da imagem](https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images).
57
+
*`imageSizes`: uma string. Para uso somente com`as: "image"`. Especifica os [tamanhos da imagem](https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images).
58
58
59
-
#### Returns {/*returns*/}
59
+
#### Retorna {/*returns*/}
60
60
61
-
`preload`returns nothing.
61
+
`preload`não retorna nada.
62
62
63
-
#### Caveats {/*caveats*/}
63
+
#### Ressalvas {/*caveats*/}
64
64
65
-
*Multiple equivalent calls to`preload`have the same effect as a single call. Calls to `preload`are considered equivalent according to the following rules:
66
-
*Two calls are equivalent if they have the same `href`, except:
67
-
*If`as`is set to`image`, two calls are equivalent if they have the same `href`, `imageSrcSet`, and`imageSizes`.
68
-
*In the browser, you can call`preload`in any situation: while rendering a component, in an Effect, in an event handler, and so on.
69
-
*In server-side rendering or when rendering Server Components, `preload`only has an effect if you call it while rendering a component or in an async context originating from rendering a component. Any other calls will be ignored.
65
+
*Múltiplas chamadas equivalentes para`preload`têm o mesmo efeito que uma única chamada. As chamadas para `preload`são consideradas equivalentes de acordo com as seguintes regras:
66
+
*Duas chamadas são equivalentes se tiverem o mesmo `href`, exceto:
67
+
*Se`as`for definido como`image`, duas chamadas são equivalentes se tiverem o mesmo `href`, `imageSrcSet` e`imageSizes`.
68
+
*No navegador, você pode chamar`preload`em qualquer situação: ao renderizar um componente, em um Effect, em um manipulador de eventos, e assim por diante.
69
+
*Na renderização do lado do servidor ou ao renderizar componentes do servidor, `preload`só tem efeito se você o chamar ao renderizar um componente ou em um contexto assíncrono originado da renderização de um componente. Quaisquer outras chamadas serão ignoradas.
70
70
71
71
---
72
72
73
-
## Usage {/*usage*/}
73
+
## Uso {/*usage*/}
74
74
75
-
### Preloading when rendering {/*preloading-when-rendering*/}
75
+
### Preloading ao renderizar {/*preloading-when-rendering*/}
76
76
77
-
Call`preload`when rendering a component if you know that it or its children will use a specific resource.
77
+
Chame`preload`ao renderizar um componente se souber que ele ou seus filhos usarão um recurso específico.
78
78
79
-
<RecipestitleText="Examples of preloading">
79
+
<RecipestitleText="Exemplos de preloading">
80
80
81
-
#### Preloading an external script {/*preloading-an-external-script*/}
81
+
#### Preloading um script externo {/*preloading-an-external-script*/}
82
82
83
83
```js
84
84
import { preload } from'react-dom';
@@ -89,11 +89,11 @@ function AppRoot() {
89
89
}
90
90
```
91
91
92
-
If you want the browser to start executing the script immediately (rather than just downloading it), use [`preinit`](/reference/react-dom/preinit)instead. If you want to load an ESM module, use [`preloadModule`](/reference/react-dom/preloadModule).
92
+
Se você deseja que o navegador comece a executar o script imediatamente (em vez de apenas baixá-lo), use [`preinit`](/reference/react-dom/preinit)em vez disso. Se você deseja carregar um módulo ESM, use [`preloadModule`](/reference/react-dom/preloadModule).
93
93
94
94
<Solution />
95
95
96
-
#### Preloading a stylesheet {/*preloading-a-stylesheet*/}
96
+
#### Preloading uma stylesheet {/*preloading-a-stylesheet*/}
97
97
98
98
```js
99
99
import { preload } from'react-dom';
@@ -104,11 +104,11 @@ function AppRoot() {
104
104
}
105
105
```
106
106
107
-
If you want the stylesheet to be inserted into the document immediately (which means the browser will start parsing it immediately rather than just downloading it), use [`preinit`](/reference/react-dom/preinit)instead.
107
+
Se você deseja que a stylesheet seja inserida no documento imediatamente (o que significa que o navegador começará a analisá-la imediatamente em vez de apenas baixá-la), use [`preinit`](/reference/react-dom/preinit)em vez disso.
108
108
109
109
<Solution />
110
110
111
-
#### Preloading a font {/*preloading-a-font*/}
111
+
#### Preloading uma fonte {/*preloading-a-font*/}
112
112
113
113
```js
114
114
import { preload } from'react-dom';
@@ -120,11 +120,11 @@ function AppRoot() {
120
120
}
121
121
```
122
122
123
-
If you preload a stylesheet, it's smart to also preload any fonts that the stylesheet refers to. That way, the browser can start downloading the font before it's downloaded and parsed the stylesheet.
123
+
Se você fizer o preload de uma stylesheet, é inteligente também fazer o preload de quaisquer fontes às quais a stylesheet se refere. Dessa forma, o navegador pode começar a baixar a fonte antes de baixar e analisar a stylesheet.
124
124
125
125
<Solution />
126
126
127
-
#### Preloading an image {/*preloading-an-image*/}
127
+
#### Preloading uma image {/*preloading-an-image*/}
128
128
129
129
```js
130
130
import { preload } from'react-dom';
@@ -139,15 +139,15 @@ function AppRoot() {
139
139
}
140
140
```
141
141
142
-
When preloading an image, the `imageSrcSet`and`imageSizes`options help the browser [fetch the correctly sized image for the size of the screen](https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images).
142
+
Ao fazer o preload de uma imagem, as opções `imageSrcSet`e`imageSizes`ajudam o navegador a [buscar a imagem com o tamanho correto para o tamanho da tela](https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images).
143
143
144
144
<Solution />
145
145
146
146
</Recipes>
147
147
148
-
### Preloading in an event handler {/*preloading-in-an-event-handler*/}
148
+
### Preloading em um manipulador de eventos {/*preloading-in-an-event-handler*/}
149
149
150
-
Call`preload`in an event handler before transitioning to a page or state where external resources will be needed. This gets the process started earlier than if you call it during the rendering of the new page or state.
150
+
Chame`preload`em um manipulador de eventos antes de fazer a transição para uma página ou estado onde recursos externos serão necessários. Isso inicia o processo mais cedo do que se você o chamasse durante a renderização da nova página ou estado.
0 commit comments