Skip to content

Commit 5902392

Browse files
bagoesrexresir014
andauthored
docs: translate preinit (#765)
Co-authored-by: Resi Respati <[email protected]>
1 parent 5542e78 commit 5902392

File tree

1 file changed

+37
-31
lines changed

1 file changed

+37
-31
lines changed

src/content/reference/react-dom/preinit.md

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,21 @@
22
title: preinit
33
---
44

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+
511
<Note>
612

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

915
</Note>
1016

1117
<Intro>
1218

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

1521
```js
1622
preinit("https://example.com/script.js", {as: "script"});
@@ -22,11 +28,11 @@ preinit("https://example.com/script.js", {as: "script"});
2228

2329
---
2430

25-
## Reference {/*reference*/}
31+
## Referensi {/*reference*/}
2632

2733
### `preinit(href, options)` {/*preinit*/}
2834

29-
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`.
3036

3137
```js
3238
import { preinit } from 'react-dom';
@@ -38,42 +44,42 @@ function AppRoot() {
3844

3945
```
4046

41-
[See more examples below.](#usage)
47+
[Lihat contoh lainnya di bawah ini.](#usage)
4248

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

45-
#### Parameters {/*parameters*/}
51+
#### Parameter {/*parameters*/}
4652

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`.
5561

56-
#### Returns {/*returns*/}
62+
#### Kembalian {/*returns*/}
5763

58-
`preinit` returns nothing.
64+
`preinit` tidak mengembalikan apa pun.
5965

60-
#### Caveats {/*caveats*/}
66+
#### Peringatan {/*caveats*/}
6167

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

6672
---
6773

68-
## Usage {/*usage*/}
74+
## Penggunaan {/*usage*/}
6975

70-
### Preiniting when rendering {/*preiniting-when-rendering*/}
76+
### Preiniting awal saat me-render {/*preiniting-when-rendering*/}
7177

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

7480
<Recipes titleText="Examples of preiniting">
7581

76-
#### Preiniting an external script {/*preiniting-an-external-script*/}
82+
#### Preiniting skrip eksternal {/*preiniting-an-external-script*/}
7783

7884
```js
7985
import { preinit } from 'react-dom';
@@ -84,11 +90,11 @@ function AppRoot() {
8490
}
8591
```
8692

87-
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).
8894

8995
<Solution />
9096

91-
#### Preiniting a stylesheet {/*preiniting-a-stylesheet*/}
97+
#### Preiniting stylesheet {/*preiniting-a-stylesheet*/}
9298

9399
```js
94100
import { preinit } from 'react-dom';
@@ -99,17 +105,17 @@ function AppRoot() {
99105
}
100106
```
101107

102-
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.
103109

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

106112
<Solution />
107113

108114
</Recipes>
109115

110-
### Preiniting in an event handler {/*preiniting-in-an-event-handler*/}
116+
### Preiniting pada event handler {/*preiniting-in-an-event-handler*/}
111117

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

114120
```js
115121
import { preinit } from 'react-dom';

0 commit comments

Comments
 (0)