Study/React
this.props
더 멋진 세상을 꿈꾸는 개발자
2020. 5. 27. 10:18
this.props
이전에,
당신은 컴포넌트들이 interact할 수 있는 한가지 방법을 배웠다. : 컴포넌트는 또 다른 컴포넌트를 렌더할 수 있다.
이 레슨에서,
당신은 컴포넌트가 interact할 수 있는 또 다른 방법에 대해 배울것이다 : 컴포넌트는 또다른 컴포넌트에 정보를 전달 할 수 있다.
한 컴포넌트에서 다른 것으로 전달되는 정보는 "props"로 알려진다.
Access a Component's props
모든 컴포넌트는 props라 불리는 무언가를 가지고있다.
컴포넌트의 props는 객체이다.
컴포넌트의 props객체를 보기 위해, 당신은 this.props표현식을 사용할 수 있다.
여기 render method안에 사용되는 this.props의 예시를 보자.
render() {
console.log("Props object comin' up!");
console.log(this.props);
console.log("That was my props object!");
return <h1>Hello world</h1>;
}
this.props에서 정보의 대부분은 꽤 사용성이 적다.
this.props 의 대부분의 정보는 꽤 쓸모없다! 하지만 그 중 일부는 보시다시피 매우 중요하다.
https://www.codecademy.com/courses/react-101/lessons/this-props/exercises/pass-props-component