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
Call`createFactory(type)`to create a factory function which produces React elements of a given `type`.
29
+
Panggil`createFactory(type)`untuk membuat sebuah fungsi pabrik (*factory function*) yang menghasilkan elemen-elemen React dengan `type` yang ditentukan.
30
30
31
31
```js
32
32
import { createFactory } from'react';
33
33
34
34
constbutton=createFactory('button');
35
35
```
36
36
37
-
Then you can use it to create React elements without JSX:
37
+
Lalu Anda dapat menggunakannya untuk membuat elemen-elemen React tanpa JSX:
38
38
39
39
```js
40
40
exportdefaultfunctionApp() {
41
41
returnbutton({
42
42
onClick: () => {
43
-
alert('Clicked!')
43
+
alert('Sudah diklik!')
44
44
}
45
-
}, 'Click me');
45
+
}, 'Klik saya');
46
46
}
47
47
```
48
48
49
-
[See more examples below.](#usage)
49
+
[Lihat contoh-contoh lainnya di bawah ini.](#usage)
50
50
51
-
#### Parameters {/*parameters*/}
51
+
#### Parameter {/*parameters*/}
52
52
53
-
*`type`: The`type`argument must be a valid React component type. For example, it could be a tag name string (such as `'div'`or`'span'`), or a React component (a function, a class, or a special component like[`Fragment`](/reference/react/Fragment)).
53
+
*`type`: Argumen`type`harus merupakan tipe komponen React yang valid. Misalnya, bisa berupa string nama tag (seperti `'div'`atau`'span'`), atau komponen React (fungsi, kelas, atau komponen khusus seperti[`Fragment`](/reference/react/Fragment)).
54
54
55
-
#### Returns {/*returns*/}
55
+
#### Kembalian {/*returns*/}
56
56
57
-
Returns a factory function. That factory function receives a`props`object as the first argument, followed by a list of `...children` arguments, and returns a React element with the given `type`, `props` and`children`.
57
+
Mengembalikan sebuah fungsi pabrik. Fungsi pabrik tersebut menerima objek`props`sebagai argumen pertama, diikuti oleh daftar argumen `...children`, dan mengembalikan elemen React dengan `type`, `props`, dan`children` yang diberikan.
58
58
59
59
---
60
60
61
-
## Usage {/*usage*/}
61
+
## Penggunaan {/*usage*/}
62
62
63
-
### Creating React elements with a factory {/*creating-react-elements-with-a-factory*/}
63
+
### Membuat elemen-elemen React dengan menggunakan fungsi pabrik {/*creating-react-elements-with-a-factory*/}
64
64
65
-
Although most React projects use [JSX](/learn/writing-markup-with-jsx)to describe the user interface, JSX is not required. In the past, `createFactory`used to be one of the ways you could describe the user interface without JSX.
65
+
Meskipun sebagian besar proyek React menggunakan [JSX](/learn/writing-markup-with-jsx)untuk mendeskripsikan antarmuka pengguna, JSX tidak diperlukan. Di masa lalu, `createFactory`digunakan sebagai salah satu cara untuk mendeskripsikan antarmuka pengguna tanpa menggunakan JSX
66
66
67
-
Call`createFactory`to create a *factory function* for a specific element type like`'button'`:
67
+
Panggil`createFactory`untuk membuat sebuah fungsi pabrik untuk tipe elemen tertentu seperti`'button'`:
68
68
69
69
```js
70
70
import { createFactory } from'react';
71
71
72
72
constbutton=createFactory('button');
73
73
```
74
74
75
-
Calling that factory function will produce React elements with the props and children you have provided:
75
+
Memanggil fungsi pabrik tersebut akan menghasilkan elemen-elemen React dengan props dan children yang telah Anda berikan:
This is how`createFactory`was used as an alternative to JSX. However, `createFactory`is deprecated, and you should not call`createFactory`in any new code. See how to migrate away from`createFactory` below.
95
+
Berikut adalah bagaimana`createFactory`digunakan sebagai alternatif untuk JSX. Namun, `createFactory`sudah tidak digunakan lagi (deprecated), dan Anda sebaiknya tidak menggunakan`createFactory`dalam kode baru. Berikut adalah cara melakukan migrasi dari`createFactory`:
96
96
97
97
---
98
98
99
-
## Alternatives {/*alternatives*/}
99
+
## Alternatif {/*alternatives*/}
100
100
101
-
### Copying`createFactory`into your project {/*copying-createfactory-into-your-project*/}
101
+
### Menyalin`createFactory`ke dalam proyek Anda {/*copying-createfactory-into-your-project*/}
102
102
103
-
If your project has many `createFactory` calls, copy this`createFactory.js`implementation into your project:
103
+
Jika proyek Anda memiliki banyak panggilan `createFactory`, salin implementasi`createFactory.js`ini ke dalam proyek Anda:
If you have a few`createFactory`calls that you don't mind porting manually, and you don't want to use JSX, you can replace every call a factory function with a [`createElement`](/reference/react/createElement) call. For example, you can replace this code:
137
+
Jika Anda memiliki beberapa panggilan`createFactory`yang tidak masalah untuk dipindahkan secara manual, dan Anda tidak ingin menggunakan JSX, Anda dapat menggantikan setiap panggilan fungsi pabrik dengan panggilan [`createElement`](/reference/react/createElement). Sebagai contoh, Anda dapat menggantikan kode ini:
0 commit comments