리액트 라이브세션 2

J·2025년 7월 1일

stack, heap,
Object.is(a, b) : a와 b의 참조값

stack heap
address | value address | value
add1

불변성을 지킨다 : 참조 주소당 한 값만 있게 한다.

깊은 복사
structuredClone

간단한 출력 함수 만들고
node --print-bytecode --print-bytecode-filter=test teset.js로 실행하면 바이트 코드 메시지가 나옴

apple@appleui-MacBookPro pandora-js % node --print-bytecode --print-bytecode-filter=test test.js
[generated bytecode for function: test (0x3bd73f9e0fd9 <SharedFunctionInfo test>)]
Bytecode length: 4
Parameter count 1
Register count 1
Frame size 8
OSR nesting level: 0
Bytecode Age: 0
   39 S> 0x3bd73f9e1bde @    0 : 13 00             LdaConstant [0]
         0x3bd73f9e1be0 @    2 : c3                Star0 
   74 S> 0x3bd73f9e1be1 @    3 : a8                Return 
Constant pool (size = 1)
0x3bd73f9e1b91: [FixedArray] in OldSpace
 - map: 0x3bd7f80812c1 <Map>
 - length: 1
           0: 0x3bd73f9e0e19 <String[14]: #this is string>
Handler Table (size = 0)
Source Position Table (size = 7)
0x3bd73f9e1be9 <ByteArray[7]>

string은 stack에 저장되지 않음 / number는 stack에 저장됨

우리가 알고 있는 개념들을 어떻게 눈으로 확인할 것인가? << 이걸 해봐야
리액트에서 상태관리를 하는 건 도대체 어떻게 하는 것인가?

소스코드를 보는 법

최적화

  • 리렌더 가능성 많은가? 많으면 어디에 의존하나? -> 꼬리를 물어서 최종적인 것만 의존성 배열에 넣는다.

0개의 댓글