component2 Component 의 LifeCycle 예제 책보고 예제를 만들어보긴했는데 아직 완벽하게 숙지되지는 않는다. console 창을 켜놓고 계속 클릭 + 소스 분석을 더 해봐야 숙지할수있을것 같다. App.js 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 import React, { Component } from "react"; import LifeCycleSample from "./LifeCycleSample"; // 랜덤 색상을 생성합니다. function getRandomColor() { return "#" + Math.floor(Math.random() * 16777215).toString(16); } class App extends Component { .. 2021. 4. 22. Component 의 LifeCycle 라이프사이클 메서드에 Will 접두사가 붙은 메서드는 어떤 작업을 작동하기 전 실행 Did 접두사가 붙은 메서드는 어떤 작업을 작동한 후 실행 render() 함수 constructor 메서드 getDerivedStateFromProps 메서드 componentDidMount 메서드 shouldComponentUpdate 메서드 getSnapshotBeforeUpdate 메서드 componentDidUpdate 메서드 componentWillUnmount 메서드 라이프사이클 메서드는 세가지 카테고리로 나눌수 있다. 마운트 - DOM이 생성되고 웹 브라우저상에 나타나는 것. 업데이트 - props 나 state 가 바뀔때, 부모 컴포넌트가 리랜더링될 때, this.forceUpdate로 강제로 랜더링을 트.. 2021. 4. 22. 이전 1 다음