React class component 라이프사이클 함수
1. constructor 함수 - 생성자 함수로서 클래스 컴포넌트에서 State를 사용하지 않아 State의 초깃값을 설정할 필요가 없을때는 생략 가능 ex) constructor(props: Props) { super(props); this.state = { counter: 0, }; } - 생성자 함수는 해당 클래스 컴포넌트가 생성될 때에 한 번만 호출된다. 2. render 함수 - render 함수는 클래스 컴포넌트의 화면 표시부분을 정의하는데 사용 ex) render() { const { counter } = this.state; return ( Counter App ); - render 함수는 부모 컴포넌트로부터 받은 Props값이 변경되거나 클래스 컴포넌트 안에서 this.setState를..
2023.08.13