▶ 부모로부터 상속받은 속성( property ) 으로, 컴포넌트 밖에서 주어지는 데이터이다.
컴포넌트 외부에서 데이터를 전달받는것들로, HTML 로 예를 들자면,
내가 사용하려는 컴포넌트의 외부에서부터 전달받은 Props 들이 attrubute 와, attribute의 값들로 적용된다고 생각하면 된다.
// App.JSX
class App extends Component {
// title : 멤버변수
title = "강주현";
// handle : 멤버함수
handle = () => {
console.log("버튼을 눌렀다.");
};
render() {
return <LikeButton title={this.title} onClick={this.handle} />;
}
}
// LikeButton.JSX
class LikeButton extends Component {
state = {
numberOfLikes: 'flower',
};
render() {
console.log(this.props); // { title: '강주현', onCilck : f}
console.log(this.state); // { numberOfLikes : 'flower'}
return <button className={this.props.title}>{this.state.numberOfLikes}</button>;
// <button class="강주현">flower</button>
}
}
/* 해석 :
LikeButton 컴포넌트는,
LikeButton 의 부모 컴포넌트인, App 컴포넌트로부터 (App 컴포넌트에 있는)
title 이라는 멤버변수와 handle 이라는 멤버변수를 인수로 전달받았다.*/
}