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/preinit.md
+37-31Lines changed: 37 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,15 +2,21 @@
2
2
title: preinit
3
3
---
4
4
5
+
<Canary>
6
+
7
+
Fungsi `preinit` saat ini hanya tersedia di kanal Canary dan eksperimental React. Pelajari lebih lanjut tentang [kanal rilis React di sini](/community/versioning-policy#all-release-channels).
8
+
9
+
</Canary>
10
+
5
11
<Note>
6
12
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.
13
+
[Framework berbasis React](/learn/start-a-new-react-project)sering kali menangani pemuatan sumber daya untuk Anda, jadi Anda mungkin tidak perlu memanggil API ini sendiri. Lihat dokumentasi framework Anda untuk detailnya.
8
14
9
15
</Note>
10
16
11
17
<Intro>
12
18
13
-
`preinit`lets you eagerly fetch and evaluate a stylesheet or external script.
19
+
`preinit`memungkinkan Anda mengambil dan mengevaluasi *stylesheet* atau skrip eksternal dengan cepat.
To preinit a script or stylesheet, call the`preinit`function from`react-dom`.
35
+
Untuk melakukan inisialisasi terhadap sebuah skrip atau *stylesheet*, panggil fungsi`preinit`dari`react-dom`.
30
36
31
37
```js
32
38
import { preinit } from'react-dom';
@@ -38,42 +44,42 @@ function AppRoot() {
38
44
39
45
```
40
46
41
-
[See more examples below.](#usage)
47
+
[Lihat contoh lainnya di bawah ini.](#usage)
42
48
43
-
The`preinit`function provides the browser with a hint that it should start downloading and executing the given resource, which can save time. Scripts that you`preinit`are executed when they finish downloading. Stylesheets that you preinit are inserted into the document, which causes them to go into effect right away.
49
+
Fungsi`preinit`memberikan petunjuk kepada browser bahwa untuk mulai mengunduh dan mengeksekusi sumber daya yang diberikan, yang dapat menghemat waktu. Skrip yang kamu`preinit`akan dieksekusi segera setelah selesai diunduh. *Stylesheet* yang kamu `preinit` akan langsung dimasukkan ke dalam dokumen, sehingga langsung berlaku saat itu juga.
44
50
45
-
#### Parameters {/*parameters*/}
51
+
#### Parameter {/*parameters*/}
46
52
47
-
*`href`: a string. The URL of the resource you want to download and execute.
48
-
*`options`: an object. It contains the following properties:
49
-
*`as`: a required string. The type of resource. Its possible values are`script` and `style`.
50
-
*`precedence`: a string. Required with stylesheets. Says where to insert the stylesheet relative to others. Stylesheets with higher precedence can override those with lower precedence. The possible values are`reset`, `low`, `medium`, `high`.
51
-
*`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`.
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
-
*`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.
54
-
*`fetchPriority`: a string. Suggests a relative priority for fetching the resource. The possible values are `auto` (the default), `high`, and`low`.
53
+
*`href`: sebuah string. URL sumber daya yang ingin Anda unduh dan jalankan.
54
+
*`options`: sebuah objek. Ini berisi properti-properti berikut:
55
+
*`as`: sebuah string yang wajib. Jenis sumber daya. Nilai yang dapat digunakan adalah`script` and `style`.
56
+
*`precedence`: sebuah string. Wajib diisi untuk stylesheet. Menunjukkan di mana stylesheet akan disisipkan relatif terhadap stylesheet lainnya. Stylesheet dengan prioritas lebih tinggi dapat menimpa(override) stylesheet dengan prioritas lebih rendah. Nilai yang memungkinkan adalah:`reset`, `low`, `medium`, `high`.
57
+
*`crossOrigin`: sebuah string. [Kebijakan CORS](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin)yang akan digunakan. Nilai yang dapat digunakan adalah `anonymous`dan`use-credentials`.
58
+
*`integrity`: sebuah string. *Hash* kriptografi sumber daya, untuk [memverifikasi keasliannya](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity).
59
+
*`nonce`: sebuah string. Sebuah [*nonce* kriptografi untuk mengizinkan sumber daya](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce)ketika menggunakan *Content Security Policy* yang ketat.
60
+
*`fetchPriority`: sebuah string. Menyarankan prioritas relatif untuk mengambil sumber daya. Nilai yang dapat digunakan adalah `auto` (default), `high`, dan`low`.
55
61
56
-
#### Returns {/*returns*/}
62
+
#### Kembalian {/*returns*/}
57
63
58
-
`preinit`returns nothing.
64
+
`preinit`tidak mengembalikan apa pun.
59
65
60
-
#### Caveats {/*caveats*/}
66
+
#### Peringatan {/*caveats*/}
61
67
62
-
*Multiple calls to `preinit`with the same `href`have the same effect as a single call.
63
-
*In the browser, you can call`preinit`in any situation: while rendering a component, in an Effect, in an event handler, and so on.
64
-
*In server-side rendering or when rendering Server Components, `preinit`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.
68
+
*Beberapa pemanggilan `preinit`dengan `href`memiliki efek yang sama dengan panggilan tunggal.
69
+
*Di browser, Anda dapat memanggil`preinit`dalam situasi apa pun: saat me-*render* komponen, di *Effect*, di *event handler*, dan sebagainya.
70
+
*Dalam rendering sisi server atau saat me-render Komponen Server, `preinit`hanya memiliki efek jika Anda memanggilnya saat me-render komponen atau dalam konteks asinkronisasi yang berasal dari rendering komponen. Pemanggilan lainnya akan diabaikan.
65
71
66
72
---
67
73
68
-
## Usage {/*usage*/}
74
+
## Penggunaan {/*usage*/}
69
75
70
-
### Preiniting when rendering {/*preiniting-when-rendering*/}
76
+
### Preiniting awal saat me-render {/*preiniting-when-rendering*/}
71
77
72
-
Call`preinit`when rendering a component if you know that it or its children will use a specific resource, and you're OK with the resource being evaluated and thereby taking effect immediately upon being downloaded.
78
+
Panggil`preinit`saat me-*render* komponen jika Anda mengetahui bahwa komponen tersebut atau anak komponennya akan menggunakan sumber daya tertentu, dan Anda setuju sumber daya tersebut langsung dievaluasi serta berlaku segera setelah selesai diunduh.
73
79
74
80
<RecipestitleText="Examples of preiniting">
75
81
76
-
#### Preiniting an external script {/*preiniting-an-external-script*/}
If you want the browser to download the script but not to execute it right away, use[`preload`](/reference/react-dom/preload) instead. If you want to load an ESM module, use[`preinitModule`](/reference/react-dom/preinitModule).
93
+
Jika Anda ingin agar browser hanya mengunduh skrip tanpa langsung mengeksekusinya, gunakan[`preload`](/reference/react-dom/preload). Jika Anda ingin memuat modul ESM, gunakan[`preinitModule`](/reference/react-dom/preinitModule).
88
94
89
95
<Solution />
90
96
91
-
#### Preiniting a stylesheet {/*preiniting-a-stylesheet*/}
The`precedence`option, which is required, lets you control the order of stylesheets within the document. Stylesheets with higher precedence can overrule those with lower precedence.
108
+
Opsi`precedence`yang wajib diisi memungkinkan Anda mengontrol urutan stylesheet di dalam dokumen. Stylesheet dengan prioritas lebih tinggi dapat menimpa stylesheet dengan prioritas lebih rendah.
103
109
104
-
If you want to download the stylesheet but not to insert it into the document right away, use[`preload`](/reference/react-dom/preload) instead.
110
+
Jika Anda ingin mengunduh stylesheet tanpa langsung menyisipkannya ke dalam dokumen, gunakan[`preload`](/reference/react-dom/preload).
105
111
106
112
<Solution />
107
113
108
114
</Recipes>
109
115
110
-
### Preiniting in an event handler {/*preiniting-in-an-event-handler*/}
116
+
### Preiniting pada event handler {/*preiniting-in-an-event-handler*/}
111
117
112
-
Call`preinit`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.
118
+
Panggil`preinit`dalam *event handler* sebelum bertransisi ke halaman atau state yang membutuhkan sumber daya eksternal. Hal ini akan memulai proses lebih awal dibandingkan jika Anda memanggilnya saat merender halaman atau state baru.
0 commit comments