3.12 Working With Props
Props is simply an object that gives us acces to all the attributes we pass to our own React component.
There is one slight difference in the two ways you define React components:
Added
this
inclass components
- Class
- Function
class Person extends React.Component {
render() {
return (
<p>
I'm {this.props.name}
</p>
)
}
}
const person = (props) => {
return (
<p>
I'm {props.name}
</p>
)
}