라이프 사이클의 동작
여러 개의 컴포넌트의 라이프 사이클의 동작 방식
한 개의 컴포넌트에서의 라이프 사이클 동작 순서 파악하기



두 개의 컴포넌트, 두 개의 라이프사이클


Last updated
여러 개의 컴포넌트의 라이프 사이클의 동작 방식





Last updated
import React, { Component } from 'react';
import './App.css';
class App extends Component {
constructor(props) {
super(props);
console.log('App: constructor');
}
componentDidMount() {
console.log('App: componentDidMount');
}
componentDidUpdate() {
console.log('App: componentDidUpdate');
}
componentWillUnmount() {
console.log('App: componentWillUnmount');
}
render() {
console.log('App: render');
return (
<div className="App">
Life cycle test
<Child />
</div>
);
}
}
class Child extends Component {
constructor(props) {
super(props);
console.log('Child: constructor');
}
componentDidMount() {
console.log('Child: componentDidMount');
}
componentDidUpdate() {
console.log('Child: componentDidUpdate');
}
componentWillUnmount() {
console.log('Child: componentWillUnmount');
}
render() {
console.log('Child: render');
return <div className="App">Life cycle test</div>;
}
}
export default App;