ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [React] componentDidMount(), setTimeout()
    ComputerScience/React 2020. 7. 11. 21:56
    componentDidMount(){
        setTimeout(() => {
          this.setState({isLoading : false});
        }, 6000);
      }

    App 컴포넌트가 그려지면 (render() 함수가 실행되면) 호출되는 생명주기 함수는 componentDidMount() 이다.

     

    setTimeout()

    첫번째 인자로 전달한 함수를 두번째 인자로 전달한 값 후에 실행한다.

    코드에서 setState함수를 6000ms 즉, 6초 뒤에 출력해준다.

    'ComputerScience > React' 카테고리의 다른 글

    [React] SetState  (0) 2020.07.11

    댓글

Designed by Tistory.