State

내 할일 잘 하기·2023년 2월 21일
0

React

목록 보기
3/9

State는 컴포넌트 내의 ‘상태’이다.

  • 자신의 출력값을 변경할 수 있다.
  • 절대로 직접 수정하지 말고 setState 사용. ( = 비동기적일 수 있음 )

Life-Cycle

  • Class component → State Life Cycle임.
    • constructor : state 초기화 및 메서드 바인딩
    • componentDidMount : Dom 노드 초기화 및 데이터 fetch
    • componentWillUnmount : 타이머 제거 및 요청 취소 및 구독 해제
  • Funtional component → Hook으로 대부분 구현 가능함.
    • componentDidMount : useEffect로 빈 배열을 넣어줌
    • componentWillUnmount : cleanUp 할 때 return으로.
profile
함께 일하고싶은 개발자로 기억될래요

0개의 댓글