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
To look up a host, call the `prefetchDNS`function from`react-dom`.
23
+
Para procurar um host, chame a função `prefetchDNS`de`react-dom`.
24
24
25
25
```js
26
26
import { prefetchDNS } from'react-dom';
@@ -32,34 +32,34 @@ function AppRoot() {
32
32
33
33
```
34
34
35
-
[See more examples below.](#usage)
35
+
[Veja mais exemplos abaixo.](#usage)
36
36
37
-
The prefetchDNS function provides the browser with a hint that it should look up the IP address of a given server. If the browser chooses to do so, this can speed up the loading of resources from that server.
37
+
A função prefetchDNS fornece ao navegador uma dica de que ele deve procurar o endereço IP de um determinado servidor. Se o navegador optar por fazê-lo, isso pode acelerar o carregamento de recursos desse servidor.
38
38
39
-
#### Parameters {/*parameters*/}
39
+
#### Parâmetros {/*parameters*/}
40
40
41
-
*`href`: a string. The URL of the server you want to connect to.
41
+
*`href`: uma string. A URL do servidor que você quer se conectar.
42
42
43
-
#### Returns {/*returns*/}
43
+
#### Retorna {/*returns*/}
44
44
45
-
`prefetchDNS`returns nothing.
45
+
`prefetchDNS`não retorna nada.
46
46
47
-
#### Caveats {/*caveats*/}
47
+
#### Ressalvas {/*caveats*/}
48
48
49
-
*Multiple calls to`prefetchDNS`with the same server have the same effect as a single call.
50
-
*In the browser, you can call`prefetchDNS`in any situation: while rendering a component, in an Effect, in an event handler, and so on.
51
-
*In server-side rendering or when rendering Server Components, `prefetchDNS`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.
52
-
*If you know the specific resources you'll need, you can call [other functions](/reference/react-dom/#resource-preloading-apis)instead that will start loading the resources right away.
53
-
*There is no benefit to prefetching the same server the webpage itself is hosted from because it's already been looked up by the time the hint would be given.
54
-
*Compared with [`preconnect`](/reference/react-dom/preconnect), `prefetchDNS`may be better if you are speculatively connecting to a large number of domains, in which case the overhead of preconnections might outweigh the benefit.
49
+
*Múltiplas chamadas para`prefetchDNS`com o mesmo servidor têm o mesmo efeito de uma única chamada.
50
+
*No navegador, você pode chamar`prefetchDNS`em qualquer situação: durante a renderização de um componente, em um Effect, em um manipulador de eventos, e assim por diante.
51
+
*Em renderização do lado do servidor ou ao renderizar Componentes do Servidor, `prefetchDNS`só tem efeito se você chamá-lo durante a renderização de um componente ou em um contexto assíncrono originado da renderização de um componente. Quaisquer outras chamadas serão ignoradas.
52
+
*Se você souber os recursos específicos de que precisará, poderá chamar [outras funções](/reference/react-dom/#resource-preloading-apis)em vez disso, que começarão a carregar os recursos imediatamente.
53
+
*Não há benefício em fazer o prefetch do mesmo servidor em que a própria página da web é hospedada, porque ele já foi pesquisado no momento em que a dica seria dada.
54
+
*Em comparação com [`preconnect`](/reference/react-dom/preconnect), `prefetchDNS`pode ser melhor se você estiver se conectando especulativamente a um grande número de domínios, caso em que a sobrecarga de preconexões pode superar o benefício.
55
55
56
56
---
57
57
58
-
## Usage {/*usage*/}
58
+
## Uso {/*usage*/}
59
59
60
-
### Prefetching DNS when rendering {/*prefetching-dns-when-rendering*/}
60
+
### Prefetching DNS ao renderizar {/*prefetching-dns-when-rendering*/}
61
61
62
-
Call`prefetchDNS`when rendering a component if you know that its children will load external resources from that host.
62
+
Chame`prefetchDNS`ao renderizar um componente se você souber que seus filhos carregarão recursos externos desse host.
63
63
64
64
```js
65
65
import { prefetchDNS } from'react-dom';
@@ -70,9 +70,9 @@ function AppRoot() {
70
70
}
71
71
```
72
72
73
-
### Prefetching DNS in an event handler {/*prefetching-dns-in-an-event-handler*/}
73
+
### Prefetching DNS em um manipulador de eventos {/*prefetching-dns-in-an-event-handler*/}
74
74
75
-
Call`prefetchDNS`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.
75
+
Chame`prefetchDNS`em um manipulador de eventos antes de fazer a transição para uma página ou estado em que 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