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/Component.md
+4-116Lines changed: 4 additions & 116 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,11 +50,7 @@ Hanya *method* `render` yang diperlukan, *method* yang lain adalah opsional.
50
50
51
51
### `context` {/*context*/}
52
52
53
-
<<<<<<< HEAD
54
-
[Context](/learn/passing-data-deeply-with-context) dari sebuah *class component* tersedia sebagai `this.context`. Ini hanya tersedia jika Anda menentukan context *yang mana* yang ingin Anda terima menggunakan [`static contextType`](#static-contexttype) (modern) atau [`static contextTypes`](#static-contexttypes) (deprecated).
55
-
=======
56
-
The [context](/learn/passing-data-deeply-with-context) of a class component is available as `this.context`. It is only available if you specify *which* context you want to receive using [`static contextType`](#static-contexttype).
57
-
>>>>>>> 50d6991ca6652f4bc4c985cf0c0e593864f2cc91
53
+
[Context](/learn/passing-data-deeply-with-context) dari sebuah *class component* tersedia sebagai `this.context`. Ini hanya tersedia jika Anda menentukan context *yang mana* yang ingin Anda terima menggunakan [`static contextType`](#static-contexttype).
58
54
59
55
*Class component* hanya bisa membaca satu *context* pada satu waktu.
60
56
@@ -109,21 +105,6 @@ Membaca `this.props` pada *class components* setara dengan [mendeklarasikan prop
109
105
110
106
---
111
107
112
-
<<<<<<< HEAD
113
-
### `refs` {/*refs*/}
114
-
115
-
<Deprecated>
116
-
117
-
API ini akan dihapus pada versi mayor React di masa depan. [Gunakan `createRef` sebagai gantinya.](/reference/react/createRef)
118
-
119
-
</Deprecated>
120
-
121
-
Memungkinkan Anda mengakses [legacy string refs](https://reactjs.org/docs/refs-and-the-dom.html#legacy-api-string-refs) pada komponen ini.
122
-
123
-
---
124
-
125
-
=======
126
-
>>>>>>> 50d6991ca6652f4bc4c985cf0c0e593864f2cc91
127
108
### `state` {/*state*/}
128
109
129
110
*State* dari *class component* tersedia sebagai `this.state`. *Field state* harus berupa objek. Jangan mengubah *state* secara langsung. Jika Anda ingin mengubah *state*, panggil `setState` dengan *state* baru.
@@ -501,21 +482,6 @@ Membaca sumber data eksternal dan memaksa komponen kelas untuk me-*render* ulang
501
482
502
483
---
503
484
504
-
<<<<<<< HEAD
505
-
### `getChildContext()` {/*getchildcontext*/}
506
-
507
-
<Deprecated>
508
-
509
-
API ini akan dihapus di versi mayor React yang akan datang. [Gunakan `Context.Provider` sebagai gantinya.](/reference/react/createContext#provider)
510
-
511
-
</Deprecated>
512
-
513
-
Memungkinkan Anda menentukan nilai untuk [legacy context](https://reactjs.org/docs/legacy-context.html) yang disediakan oleh komponen ini.
Jika Anda mengimplementasikan `getSnapshotBeforeUpdate`, React akan segera memanggilnya sebelum React memperbarui DOM. Ini memungkinkan komponen Anda untuk menangkap beberapa informasi dari DOM (e.g. posisi*scroll*) sebelum berpotensi diubah. Nilai apa pun yang dikembalikan oleh *lifecycle method* ini akan diteruskan sebagai parameter ke [`componentDidUpdate`.](#componentdidupdate)
@@ -748,15 +714,9 @@ React memanggil `shouldComponentUpdate` sebelum *render*-ing ketika *props* baru
-`nextProps`:*Props* berikutnya yang akan diterima komponen dari komponen induknya. Bandingkan`nextProps` dengan [`this.props`](#props) untuk menentukan apa yang berubah.
835
-
-`nextContext`:*Props* berikutnya yang akan diterima komponen dari penyedia terdekat. Bandingkan`nextContext` dengan [`this.context`](#context) untuk menentukan apa yang berubah. Hanya tersedia jika Anda menetapkan [`static contextType`](#static-contexttype) (modern) atau [`static contextTypes`](#static-contexttypes) (legacy).
836
-
=======
837
-
-`nextProps`: The next props that the component is about to receive from its parent component. Compare`nextProps` to [`this.props`](#props) to determine what changed.
838
-
-`nextContext`: The next context that the component is about to receive from the closest provider. Compare`nextContext` to [`this.context`](#context) to determine what changed. Only available if you specify [`static contextType`](#static-contexttype).
839
-
>>>>>>>50d6991ca6652f4bc4c985cf0c0e593864f2cc91
794
+
-`nextContext`:*Props* berikutnya yang akan diterima komponen dari penyedia terdekat. Bandingkan`nextContext` dengan [`this.context`](#context) untuk menentukan apa yang berubah. Hanya tersedia jika Anda menetapkan [`static contextType`](#static-contexttype).
API ini akan dihapus di versi mayor React yang akan datang. [Gunakan `static contextType` sebagai gantinya.](#static-contexttype)
922
-
923
-
</Deprecated>
924
-
925
-
Memungkinkan Anda menentukan [legacy context](https://reactjs.org/docs/legacy-context.html) yang dikonsumsi oleh komponen ini.
926
-
927
-
---
928
-
929
-
=======
930
-
>>>>>>>50d6991ca6652f4bc4c985cf0c0e593864f2cc91
931
859
### `static contextType` {/*static-contexttype*/}
932
860
933
861
Jika Anda ingin membaca [`this.context`](#context-instance-field) dari *class component* Anda, Anda harus menentukan *context* mana yang perlu dibaca. *Context* yang Anda tentukan sebagai `static contextType` harus berupa nilai yang dibuat sebelumnya oleh [`createContext`.](/reference/react/createContext)
@@ -1002,37 +930,6 @@ Mendefinisikan `defaultProps` pada *class components* serupa dengan menggunakan
1002
930
1003
931
---
1004
932
1005
-
<<<<<<< HEAD
1006
-
### `static propTypes` {/*static-proptypes*/}
1007
-
1008
-
Anda dapat mendefinisikan `static propTypes` bersama dengan pustaka [`prop-types`](https://www.npmjs.com/package/prop-types) untuk mendeklarasikan jenis *props* yang diterima oleh komponen Anda. Jenis ini akan diperiksa selama *render*-ing dan hanya dalam pengembangan.
1009
-
1010
-
```js
1011
-
import PropTypes from 'prop-types';
1012
-
1013
-
class Greeting extends React.Component {
1014
-
static propTypes = {
1015
-
name: PropTypes.string
1016
-
};
1017
-
1018
-
render() {
1019
-
return (
1020
-
<h1>Hello, {this.props.name}</h1>
1021
-
);
1022
-
}
1023
-
}
1024
-
```
1025
-
1026
-
<Note>
1027
-
1028
-
Kamimerekomendasikanmenggunakan [TypeScript](https://www.typescriptlang.org/) daripada memeriksa *prop types* pada *runtime*.
Jika Anda mendefinisikan `static getDerivedStateFromError`, React akan memanggilnya ketika komponen anak (termasuk anak jauh) melemparkan kesalahan selama *render*-ing. Ini memungkinkan Anda menampilkan pesan kesalahan alih-alih menghapus UI.
@@ -1395,17 +1292,9 @@ class ErrorBoundary extends React.Component {
1395
1292
}
1396
1293
1397
1294
componentDidCatch(error, info) {
1398
-
<<<<<<<HEAD
1399
-
// Contoh "componentStack":
1400
-
// in ComponentThatThrows (created by App)
1401
-
// in ErrorBoundary (created by App)
1402
-
// in div (created by App)
1403
-
// in App
1404
-
logErrorToMyService(error, info.componentStack);
1405
-
=======
1406
1295
logErrorToMyService(
1407
1296
error,
1408
-
//Example "componentStack":
1297
+
//Contoh "componentStack":
1409
1298
// in ComponentThatThrows (created by App)
1410
1299
// in ErrorBoundary (created by App)
1411
1300
// in div (created by App)
@@ -1414,7 +1303,6 @@ class ErrorBoundary extends React.Component {
1414
1303
// Warning: `captureOwnerStack` is not available in production.
0 commit comments