@@ -540,37 +540,37 @@ button {
540540let componentHooks = [];
541541let currentHookIndex = 0 ;
542542
543- // How useState works inside React (simplified ).
543+ // React 내부에서 useState가 작동하는 방식 (단순화됨 ).
544544function useState (initialState ) {
545545 let pair = componentHooks[currentHookIndex];
546546 if (pair) {
547- // This is not the first render,
548- // so the state pair already exists .
549- // Return it and prepare for next Hook call .
547+ // 첫 번째 렌더링이 아니므로
548+ // state 쌍이 이미 존재합니다 .
549+ // 이를 반환하고 다음 Hook 호출을 준비합니다 .
550550 currentHookIndex++ ;
551551 return pair;
552552 }
553553
554- // This is the first time we're rendering,
555- // so create a state pair and store it .
554+ // 처음 렌더링하는 것이므로
555+ // state 쌍을 생성하고 저장합니다 .
556556 pair = [initialState, setState];
557557
558558 function setState (nextState ) {
559- // When the user requests a state change,
560- // put the new value into the pair .
559+ // 사용자가 state 변경을 요청하면
560+ // 새 값을 쌍에 넣습니다 .
561561 pair[0 ] = nextState;
562562 updateDOM ();
563563 }
564564
565- // Store the pair for future renders
566- // and prepare for the next Hook call .
565+ // 이후 렌더링을 위해 쌍을 저장하고
566+ // 다음 Hook 호출을 준비합니다 .
567567 componentHooks[currentHookIndex] = pair;
568568 currentHookIndex++ ;
569569 return pair;
570570}
571571
572572function Gallery () {
573- // Each useState() call will get the next pair .
573+ // 각 useState() 호출은 다음 쌍을 가져옵니다 .
574574 const [index , setIndex ] = useState (0 );
575575 const [showMore , setShowMore ] = useState (false );
576576
@@ -583,8 +583,8 @@ function Gallery() {
583583 }
584584
585585 let sculpture = sculptureList[index];
586- // This example doesn't use React, so
587- // return an output object instead of JSX .
586+ // 이 예시는 React를 사용하지 않으므로
587+ // JSX 대신 출력 객체를 반환합니다 .
588588 return {
589589 onNextClick: handleNextClick,
590590 onMoreClick: handleMoreClick,
@@ -598,13 +598,13 @@ function Gallery() {
598598}
599599
600600function updateDOM () {
601- // Reset the current Hook index
602- // before rendering the component .
601+ // 컴포넌트를 렌더링하기 전에
602+ // 현재 Hook 인덱스를 초기화합니다 .
603603 currentHookIndex = 0 ;
604604 let output = Gallery ();
605605
606- // Update the DOM to match the output .
607- // This is the part React does for you .
606+ // 출력과 일치하도록 DOM을 업데이트합니다 .
607+ // 이 부분은 React가 대신 해줍니다 .
608608 nextButton .onclick = output .onNextClick ;
609609 header .textContent = output .header ;
610610 moreButton .onclick = output .onMoreClick ;
@@ -698,7 +698,7 @@ let sculptureList = [{
698698 alt: ' A group of bronze hippo sculptures emerging from the sett sidewalk as if they were swimming.'
699699}];
700700
701- // Make UI match the initial state .
701+ // UI를 초기 state와 일치시킵니다 .
702702updateDOM ();
703703```
704704
0 commit comments