react
STATE vs PROPS
MyaZ
2020. 6. 13. 14:41
# STATE vs PROPS
* State : POJO{} mutable to store changing component data
- 컴포넌트에 변형되는 데이터를 저장시 선언
* props : POJO{} mutable to store component configuration
- 컴포넌트의 구성 저장시 선언
## State as Props
- parent component passing down its state values as props to stateless child components.
class CountParent extends Component {
constructor(props) {
super(props);
this.state = {count:5};
}
render() {
// passing down parent state as a prop
return (
<CountChild count={this.state.count} />
);
}
}