LifeCycle 생명주기

cracKey·2022년 7월 30일
0

LifeCycle 생명주기

LifeCycle(생명주기) 메서드는 컴포넌트가 브라우저에서 나타나고, 업로드되고 사라지게 될 떄 호출되는 메서드이다.

  • 생명주기 메서드는 클래스형 컴포넌트에서만 사용 할 수 있다.
  • 함수형 컴포넌트의 useEffect와 비슷하다.

LifeCycle

크게 3가지가 있다

마운트

  • DOM이 생성되고 웹브라우저에 표시되는 것
  • 요소를 추가하는것

    메소드
    constructor()
    getDerivedStateFromProps()
    render()
    componentDidMount()

업데이트

  • 컴포넌트가 업데이트 될 때
  • 컴포넌트의 상태, props가 변경될 때 마다 업데이트

    메소드
    getDerivedStateFromProps()
    shouldComponentUpdate()
    render()
    getSnapshotBeforeUpdate()
    componentDidUpdate()

언마운트

  • 컴포넌트가 DOM을 제거 하는 경우

    메소드
    componentWillUnmount()

profile
키보드가 부서지게 / 개발공부노트

0개의 댓글