@@ -520,8 +520,8 @@ class ScrollingList extends React.Component {
520
520
}
521
521
522
522
getSnapshotBeforeUpdate(prevProps, prevState) {
523
- // Are we adding new items to the list?
524
- // Capture the scroll position so we can adjust scroll later .
523
+ // Apakah kita menambahkan item baru ke dalam list?
524
+ // Tangkap posisi scroll supaya kita dapat mengatur scroll nanti .
525
525
if (prevProps.list.length < this.props.list.length) {
526
526
const list = this.listRef.current;
527
527
return list.scrollHeight - list.scrollTop;
@@ -530,9 +530,9 @@ class ScrollingList extends React.Component {
530
530
}
531
531
532
532
componentDidUpdate(prevProps, prevState, snapshot) {
533
- // If we have a snapshot value, we've just added new items .
534
- // Adjust scroll so these new items don't push the old ones out of view .
535
- // (snapshot here is the value returned from getSnapshotBeforeUpdate)
533
+ // Apabila kita memiliki nilai snapshot, kita baru saja menambahkan item baru .
534
+ // Atur scroll supaya item-item baru ini tidak mendorong item-item lama ke luar tampilan .
535
+ // (snapshot adalah nilai yang dikembalikan dari getSnapshotBeforeUpdate)
536
536
if (snapshot !== null) {
537
537
const list = this.listRef.current;
538
538
list.scrollTop = list.scrollHeight - snapshot;
@@ -723,7 +723,7 @@ class Rectangle extends Component {
723
723
nextProps.size.height === this.props.size.height &&
724
724
nextState.isHovered === this.state.isHovered
725
725
) {
726
- // Nothing has changed, so a re- render is unnecessary
726
+ // Tidak ada yang berubah, jadi tidak perlu render ulang
727
727
return false;
728
728
}
729
729
return true;
@@ -1048,9 +1048,9 @@ class Form extends Component {
1048
1048
};
1049
1049
1050
1050
static getDerivedStateFromProps(props, state) {
1051
- // Any time the current user changes ,
1052
- // Reset any parts of state that are tied to that user.
1053
- // In this simple example, that's just the email.
1051
+ // Setiap kali user saat ini berubah ,
1052
+ // Setel ulang bagian state mana pun yang terkait ke user itu .
1053
+ // Dalam contoh simpel ini, hanya ada email.
1054
1054
if (props.userID !== state.prevUserID) {
1055
1055
return {
1056
1056
prevUserID: props.userID,
@@ -1359,12 +1359,12 @@ class ErrorBoundary extends React.Component {
1359
1359
}
1360
1360
1361
1361
static getDerivedStateFromError (error ) {
1362
- // Update state so the next render will show the fallback UI .
1362
+ // Perbarui state sehingga render selanjutnya menunjukkan UI fallback.
1363
1363
return { hasError: true };
1364
1364
}
1365
1365
1366
1366
componentDidCatch (error , info ) {
1367
- // Example "componentStack":
1367
+ // Contoh "componentStack":
1368
1368
// in ComponentThatThrows (created by App)
1369
1369
// in ErrorBoundary (created by App)
1370
1370
// in div (created by App)
@@ -1374,7 +1374,7 @@ class ErrorBoundary extends React.Component {
1374
1374
1375
1375
render () {
1376
1376
if (this .state .hasError ) {
1377
- // You can render any custom fallback UI
1377
+ // Anda dapat me- render UI fallback apa pun.
1378
1378
return this .props .fallback ;
1379
1379
}
1380
1380
@@ -1805,7 +1805,7 @@ export default function ChatRoom({ roomId }) {
1805
1805
1806
1806
` ` ` js src/ chat .js
1807
1807
export function createConnection (serverUrl , roomId ) {
1808
- // A real implementation would actually connect to the server
1808
+ // Sebuah implementasi nyata sebenarnya akan terhubung ke server.
1809
1809
return {
1810
1810
connect () {
1811
1811
console .log (' ✅ Connecting to "' + roomId + ' " room at ' + serverUrl + ' ...' );
0 commit comments