class component와 function component의 차이점

김병훈·2022년 7월 11일
0

Redux-tutorial

목록 보기
3/3
  • class component는 this.state로 상태를 가질 수 있었다.
    하지만 function component는 state를 가지지 못했다.

  • 그리고 class component는 state를 가지고 있음으로 인해서 life cycle을 가질 수 있었는데, function component는 그렇지 못했다

  • 그래서 function component에서 state,life cycle을 가질 수 있는 방법이 등장했다.

바로 react hooks

  • 상태를 가지려면 react hooks 에서 useState라는 hook을 통해서 상태를 가질 수 있다.
    그리고 useEffect를 통해서 lifeCycle도 가질 수 있게 되었다
profile
블록체인 개발자의 꿈을 위하여

0개의 댓글