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/learn/understanding-your-ui-as-a-tree.md
+45-40Lines changed: 45 additions & 40 deletions
Original file line number
Diff line number
Diff line change
@@ -1,41 +1,43 @@
1
1
---
2
-
title: Understanding Your UI as a Tree
2
+
title: Memahami UI Anda sebagai Pohon
3
3
---
4
4
5
5
<Intro>
6
6
7
-
Your React app is taking shape with many components being nested within each other. How does React keep track of your app's component structure?
7
+
Aplikasi React Anda mulai terbentuk dengan banyak komponen yang dirangkai satu sama lain. Bagaimana cara React melacak struktur komponen aplikasi Anda?
8
8
9
-
React, and many other UI libraries, model UI as a tree. Thinking of your app as a tree is useful for understanding the relationship between components. This understanding will help you debug future concepts like performance and state management.
9
+
React, dan banyak library UI lainnya, memodelkan UI sebagai sebuah pohon. Memikirkan aplikasi Anda sebagai sebuah pohon sangat berguna untuk memahami hubungan antar komponen. Pemahaman ini akan membantu Anda men-*debug* konsep-konsep di masa depan seperti kinerja dan manajemen *state*.
10
10
11
11
</Intro>
12
12
13
13
<YouWillLearn>
14
14
15
-
*How React "sees" component structures
16
-
*What a render tree is and what it is useful for
17
-
*What a module dependency tree is and what it is useful for
15
+
*Bagaimana React "melihat" struktur komponen
16
+
*Apa itu pohon *render* dan kegunaannya
17
+
*Apa itu pohon modul dependensi dan kegunaannya
18
18
19
19
</YouWillLearn>
20
20
21
-
## Your UI as a tree {/*your-ui-as-a-tree*/}
21
+
## UI Anda sebagai pohon {/*your-ui-as-a-tree*/}
22
22
23
-
Trees are a relationship model between items and UI is often represented using tree structures. For example, browsers use tree structures to model HTML ([DOM](https://developer.mozilla.org/docs/Web/API/Document_Object_Model/Introduction)) and CSS ([CSSOM](https://developer.mozilla.org/docs/Web/API/CSS_Object_Model)). Mobile platforms also use trees to represent their view hierarchy.
23
+
Pohon adalah model hubungan antara setiap bagian (*item*) dan UI yang sering direpresentasikan dengan menggunakan struktur pohon. Sebagai contoh, Peramban (*browser*) menggunakan struktur pohon untuk memodelkan HTML ([DOM](https://developer.mozilla.org/docs/Web/API/Document_Object_Model/Introduction)) dan CSS ([CSSOM](https://developer.mozilla.org/docs/Web/API/CSS_Object_Model)). Platform seluler (*mobile*) juga menggunakan pohon untuk merepresentasikan hierarki tampilan mereka.
24
24
25
-
<Diagramname="preserving_state_dom_tree"height={193}width={864}alt="Diagram with three sections arranged horizontally. In the first section, there are three rectangles stacked vertically, with labels 'Component A', 'Component B', and 'Component C'. Transitioning to the next pane is an arrow with the React logo on top labeled 'React'. The middle section contains a tree of components, with the root labeled 'A' and two children labeled 'B' and 'C'. The next section is again transitioned using an arrow with the React logo on top labeled 'React DOM'. The third and final section is a wireframe of a browser, containing a tree of 8 nodes, which has only a subset highlighted (indicating the subtree from the middle section).">
25
+
<Diagramname="preserving_state_dom_tree"height={193}width={864}alt="Diagram dengan tiga bagian yang disusun secara horizontal. Pada bagian pertama, terdapat tiga persegi panjang yang ditumpuk secara vertikal, dengan label 'Komponen A', 'Komponen B', dan 'Komponen C'. Transisi ke panel berikutnya adalah sebuah panah dengan logo React di bagian atas yang berlabel 'React'. Bagian tengah berisi sebuah pohon komponen, dengan root berlabel 'A' dan dua komponen berlabel 'B' dan 'C'. Bagian selanjutnya ditransisikan lagi menggunakan panah dengan logo React di bagian atas berlabel 'React DOM'. Bagian ketiga dan terakhir adalah wireframe dari sebuah peramban, yang berisi sebuah pohon dengan 8 *node*, yang hanya memiliki sebuah bagian yang disorot (mengindikasikan subpohon dari bagian tengah).">
26
26
27
-
React creates a UI tree from your components. In this example, the UI tree is then used to render to the DOM.
27
+
React membuat sebuah pohon UI dari komponen-komponen Anda. Pada contoh ini, pohon UI kemudian digunakan untuk me-*render* ke DOM.
28
28
</Diagram>
29
29
30
-
Like browsers and mobile platforms, React also uses tree structures to manage and model the relationship between components in a React app. These trees are useful tools to understand how data flows through a React app and how to optimize rendering and app size.
30
+
Seperti halnya peramban (*browser*) dan perangkat seluler (*mobile*) bergerak, React juga menggunakan struktur pohon untuk mengelola dan memodelkan hubungan antar komponen dalam aplikasi React. Pohon-pohon ini adalah alat yang berguna untuk memahami bagaimana data mengalir melalui aplikasi React dan bagaimana mengoptimalkan *rendering* dan ukuran aplikasi.
31
31
32
-
## The Render Tree {/*the-render-tree*/}
32
+
## Pohon *Render* {/*the-render-tree*/}
33
33
34
-
A major feature of components is the ability to compose components of other components. As we [nest components](/learn/your-first-component#nesting-and-organizing-components), we have the concept of parent and child components, where each parent component may itself be a child of another component.
34
+
Fitur utama dari komponen adalah kemampuan untuk menyusun komponen dari komponen lain. Saat kita [menyusun komponen](/learn/
, kita memiliki konsep komponen induk dan anak, di mana setiap komponen induk dapat menjadi anak dari komponen lain.
35
37
36
-
When we render a React app, we can model this relationship in a tree, known as the render tree.
38
+
Ketika kita me-*render* aplikasi React, kita dapat memodelkan hubungan ini dalam sebuah pohon, yang dikenal sebagai pohon *render*.
37
39
38
-
Here is a React app that renders inspirational quotes.
40
+
Berikut ini adalah aplikasi React yang membuat kutipan-kutipan inspiratif.
39
41
40
42
<Sandpack>
41
43
@@ -47,7 +49,7 @@ import Copyright from './Copyright';
47
49
exportdefaultfunctionApp() {
48
50
return (
49
51
<>
50
-
<FancyText title text="Get Inspired App"/>
52
+
<FancyText title text="Aplikasi Dapatkan Inspirasi"/>
51
53
<InspirationGenerator>
52
54
<Copyright year={2004} />
53
55
</InspirationGenerator>
@@ -77,9 +79,9 @@ export default function InspirationGenerator({children}) {
77
79
78
80
return (
79
81
<>
80
-
<p>Your inspirational quote is:</p>
82
+
<p>Kutipan inspiratif Anda adalah:</p>
81
83
<FancyText text={quote} />
82
-
<button onClick={next}>Inspire me again</button>
84
+
<button onClick={next}>Berikan Aku inspirasi lagi.</button>
83
85
{children}
84
86
</>
85
87
);
@@ -94,9 +96,9 @@ export default function Copyright({year}) {
94
96
95
97
```js src/quotes.js
96
98
exportdefault [
97
-
"Don’t let yesterday take up too much of today.” — Will Rogers",
98
-
"Ambition is putting a ladder against the sky.",
99
-
"A joy that's shared is a joy made double.",
99
+
"Jangan biarkan hari kemarin menyita terlalu banyak waktu di hari ini.” — Will Rogers",
100
+
"Ambisi adalah menyusun tangga menuju langit.",
101
+
"Kegembiraan yang dibagi adalah kegembiraan yang berlipat ganda.",
100
102
];
101
103
```
102
104
@@ -118,34 +120,36 @@ export default [
118
120
119
121
</Sandpack>
120
122
121
-
<Diagramname="render_tree"height={250}width={500}alt="Tree graph with five nodes. Each node represents a component. The root of the tree is App, with two arrows extending from it to 'InspirationGenerator' and 'FancyText'. The arrows are labelled with the word 'renders'. 'InspirationGenerator' node also has two arrows pointing to nodes 'FancyText' and 'Copyright'.">
123
+
<Diagram name="render_tree" height={250} width={500} alt="Graf pohon dengan lima simpul. Tiap simpul merepresentasikan sebuah komponen. Akar dari pohon ini adalah App, dengan dua anak panah yang memanjang dari akar tersebut ke 'InspirationGenerator' dan 'FancyText'. Panah-panah tersebut diberi label dengan kata 'render'. Node 'InspirationGenerator' juga memiliki dua anak panah yang mengarah ke node 'FancyText' dan 'Copyright'.
124
+
">
122
125
123
-
React creates a*render tree*, a UI tree, composed of the rendered components.
126
+
React membuat sebuah*render tree*, sebuah pohon UI, yang terdiri dari komponen-komponen yang di-*render*.
124
127
125
128
126
129
</Diagram>
127
130
128
-
From the example app, we can construct the above render tree.
131
+
Dari contoh aplikasi, kita dapat membuat pohon *render* di atas.
129
132
130
-
The tree is composed of nodes, each of which represents a component. `App`, `FancyText`, `Copyright`, to name a few, are all nodes in our tree.
133
+
Pohon ini terdiri dari beberapa simpul, yang masing-masing mewakili sebuah komponen. `App`, `FancyText`, `Copyright`, dan beberapa lainnya, merupakan beberapa simpul di dalam pohon kita.
131
134
132
-
The root node in a React render tree is the [root component](/learn/importing-and-exporting-components#the-root-component-file)of the app. In this case, the root component is `App` and it is the first component React renders. Each arrow in the tree points from a parent component to a child component.
135
+
Simpul akar (*root node*) dalam pohon *render* React adalah [root component](/learn/importing-and-exporting-components#the-root-component-file)dari aplikasi. Dalam kasus ini, Akar komponen adalah `Aplikasi` dan merupakan komponen pertama yang di-*render* oleh React. Setiap panah pada pohon menunjuk dari komponen induk ke komponen anak.
133
136
134
137
<DeepDive>
135
138
136
-
#### Where are the HTML tags in the render tree? {/*where-are-the-html-elements-in-the-render-tree*/}
139
+
#### Di mana letak dari tag HTML dalam pohon *render*?
You'll notice in the above render tree, there is no mention of the HTML tags that each component renders. This is because the render tree is only composed of React [components](learn/your-first-component#components-ui-building-blocks).
142
+
Anda akan melihat pada pohon *render* di atas, tidak disebutkan tag HTML yang di-*render* oleh setiap komponen. Hal ini dikarenakan pohon *render* hanya terdiri dari React [components](learn/your-first-component#components-ui-building-blocks).
139
143
140
-
React, as a UI framework, is platform agnostic. On react.dev, we showcase examples that render to the web, which uses HTML markup as its UI primitives. But a React app could just as likely render to a mobile or desktop platform, which may use different UI primitives like [UIView](https://developer.apple.com/documentation/uikit/uiview)or[FrameworkElement](https://learn.microsoft.com/en-us/dotnet/api/system.windows.frameworkelement?view=windowsdesktop-7.0).
144
+
React, sebagai sebuah framework UI, bersifat agnostik terhadap platform. Di react.dev, kami menampilkan contoh-contoh yang di-*render* ke web, yang menggunakan markup HTML sebagai primitif UI-nya. Tetapi aplikasi React bisa saja merender ke platform mobile atau desktop, yang mungkin menggunakan primitif UI yang berbeda seperti [UIView](https://developer.apple.com/documentation/uikit/uiview)atau[FrameworkElement](https://learn.microsoft.com/en-us/dotnet/api/system.windows.frameworkelement?view=windowsdesktop-7.0).
141
145
142
-
These platform UI primitives are not a part of React. React render trees can provide insight to our React app regardless of what platform your app renders to.
146
+
Primitif UI platform ini bukan merupakan bagian dari React. Pohon *render* React dapat memberikan wawasan kepada aplikasi React kita terlepas dari platform apa aplikasi Anda di-*render*.
143
147
144
148
</DeepDive>
145
149
146
-
A render tree represents a single render pass of a React application. With [conditional rendering](/learn/conditional-rendering), a parent component may render different children depending on the data passed.
150
+
Sebuah pohon *render* merepresentasikan sekali *render* pada aplikasi React. Dengan [perenderan kondisional](/learn/conditional-rendering), komponen induk dapat me-*render* anak yang berbeda tergantung pada data yang di-*render*.
147
151
148
-
We can update the app to conditionally render either an inspirational quote or color.
152
+
Kita dapat memperbarui aplikasi untuk me-*render* secara bersyarat sebuah kutipan inspiratif atau warna.
149
153
150
154
<Sandpack>
151
155
@@ -157,7 +161,7 @@ import Copyright from './Copyright';
157
161
exportdefaultfunctionApp() {
158
162
return (
159
163
<>
160
-
<FancyText title text="Get Inspired App"/>
164
+
<FancyText title text="Aplikasi Dapatkan Inspirasi"/>
161
165
<InspirationGenerator>
162
166
<Copyright year={2004} />
163
167
</InspirationGenerator>
@@ -194,12 +198,12 @@ export default function InspirationGenerator({children}) {
194
198
195
199
return (
196
200
<>
197
-
<p>Your inspirational {inspiration.type} is:</p>
201
+
<p>{inspiration.type} inspiratif Anda adalah:</p>
198
202
{inspiration.type==='quote'
199
203
?<FancyText text={inspiration.value} />
200
204
:<Color value={inspiration.value} />}
201
205
202
-
<button onClick={next}>Inspire me again</button>
206
+
<button onClick={next}>Berikan Aku inspirasi lagi</button>
203
207
{children}
204
208
</>
205
209
);
@@ -214,11 +218,11 @@ export default function Copyright({year}) {
214
218
215
219
```js src/inspirations.js
216
220
exportdefault [
217
-
{type:'quote', value:"Don’t let yesterday take up too much of today.” — Will Rogers"},
221
+
{type:'quote', value:"Jangan biarkan hari kemarin menyita terlalu banyak waktu di hari ini.” — Will Rogers"},
218
222
{type:'color', value:"#B73636"},
219
-
{type:'quote', value:"Ambition is putting a ladder against the sky."},
223
+
{type:'quote', value:"Ambisi adalah menyusun tangga menuju langit."},
220
224
{type:'color', value:"#256266"},
221
-
{type:'quote', value:"A joy that's shared is a joy made double."},
225
+
{type:'quote', value:"Kegembiraan yang dibagi adalah kegembiraan yang berlipat ganda."},
222
226
{type:'color', value:"#F9F2B4"},
223
227
];
224
228
```
@@ -245,9 +249,10 @@ export default [
245
249
```
246
250
</Sandpack>
247
251
248
-
<Diagramname="conditional_render_tree"height={250}width={561}alt="Tree graph with six nodes. The top node of the tree is labelled 'App' with two arrows extending to nodes labelled 'InspirationGenerator' and 'FancyText'. The arrows are solid lines and are labelled with the word 'renders'. 'InspirationGenerator' node also has three arrows. The arrows to nodes 'FancyText' and 'Color' are dashed and labelled with 'renders?'. The last arrow points to the node labelled 'Copyright' and is solid and labelled with 'renders'.">
252
+
<Diagram name="conditional_render_tree" height={250} width={561} alt="Graf pohon dengan enam simpul. Simpul teratas dari pohon diberi label 'App' dengan dua anak panah yang mengarah ke simpul-simpul yang diberi label 'InspirationGenerator' dan 'FancyText'.
253
+
Panah-panah tersebut merupakan garis solid dan diberi label dengan kata 'render'. Node 'InspirationGenerator' juga memiliki tiga anak panah. Panah ke node 'FancyText' dan 'Color' putus-putus dan diberi label 'renders? Panah terakhir mengarah ke node berlabel 'Copyright' dan berbentuk padat dan diberi label 'renders'.">
249
254
250
-
With conditional rendering, across different renders, the render tree may render different components.
255
+
Dengan perenderan kondisional, pada *render* yang berbeda, pohon *render* dapat merender komponen yang berbeda.
0 commit comments