생명 주기
컴포넌트가 만들어졌을때 ~~해줘
컴포넌트가 죽으면 ~~ 해줘 이런것
- 그리기 / render
- 그리고 난 뒤 / componentDidMount
- 그리고 난 뒤 변경 되었을 때 / componentDidUpdate
- 그리고 난 뒤 사라질 때 / componentWillUnmount
인풋창 그리고 난 뒤에 깜빡깜빡 해줘
componentDidMount() : void{ console.log("그려지고 나서 실행!!") } componentDidUpdate() : void{ console.log("변경되고 나서 실행!!") } componentWillUnmount() : void{ console.log("사라지기 전에 실행!!") }
처음 페이지를 열면 componentDidMount 실행
카운트 올리기를 실행하면
componentDidUpdate 실행
마지막으로 나가기를 눌러서 다른 경로로 이동하려하면
이동되고 componentWillUnmount 기능이 실행됨