lifecycle methods in React. > React Component의 생명주기 Method는 특정 순간에 자동으로 호출되는 Method입니다. componentDidMount: Component가 처음 Rendering 될 때 DOM에 추가된 후 호출됩니다. shouldComponentUpdate: Rendering 전 호출되어 Rerendering 필요한지 판단 후 호출됩니다. componentDidUpdate: Component가 갱신되어 Rerendering 후 호출됩니다. componentWillUnmount: Component가 DOM에서 제거되기 전 호출됩니다. getDerivedStateFromProps: Rendering 전 호출되어 Component의 상태를 props를 기반으로 업데이트할 수 있습니다. getSnapshotBeforeUpdate: Rendering 전 호출되어 Component가 DOM
출처: https://ko.reactjs.org/docs/handling-events.html! Component를 완전히 재사용하고 캡슐화하는 방법을 알아야 합니다. 위 코드와 아래 코드의 차이는 function tick과 Clock에 차이가 있습니다. ReactDOM.render 부분에 element 대신 Clock Component를 가져오면서 구현하였습니다. State는 props와 유사하지만, 비공개이며 컴포넌트에의해 제어됩니다. function에서 class로 변환하기 React.Component를 확장합니다. render() 라고 불리는 빈 메서드를 추가합니다. 함수의 내용을 render() 메서드 안으로 옮긴다. render() 내용 안에 있는 props를 this.props로 변경 남아있는 빈 함수 선언을 삭제 this.props.date를 통해 Clock date에 전달.. render