State2 LifeCycle API LifeCycle은 리액트에서 컴포넌트를 만들어낼 때 중요하다. 컴포넌트가 브라우저에서 나타날 때(Mounting), 업데이트될 때(Updating : 컴포넌트의 props나 state가 바뀔 때), 사라질 때(Unmounting) 등에 사용된다. Mounting Updating Unmounting constructor, getDerivedStateFromProps, componentDidMount getDerivedStateFromProps, shouldComponentUpdate, getSnapshotBeforeUpdate, componentDidUpdate componentWillUnmount constructor 생성자 함수이다. 우리가 만든 컴포넌트가 처음 브라우저에 나타날 때 만들어지는 과정에.. 2021. 1. 30. Props 와 State Props와 State는 리액트에서 정말 중요한 개념이다. 리액트에서 데이터를 다룰 때 사용된다. Props는 부모 컴포넌트가 자식 컴포넌트한테 값을 전달할 때 사용된다. 값을 직접 바꿀 수는 없고 부모 컴포넌트로부터 받아오기만 할 수 있다. State는 컴포넌트 내부에서 선언하며 setState로 내부에서 값을 변경할 수 있다. Props import React, { Component } from 'react'; class ChildClass extends Component { render(){ return( 이 컴포넌트는 {this.props.name} 컴포넌트 입니다. ); } } export default ChildClass; import React, { Component } from 'react.. 2021. 1. 27. 이전 1 다음