Before delving too deeply into React, I'm forcing myself to take the time to understand the most basic React concepts. This short blog post will attempt to clearly summarize the concept of props in a way that the newest of programming students can understand.
So what are props?
To put it simply:
Props (short for properties) are the arguments you pass into a React component that then render a React element.
Props can be strings, objects, arrays or functions. Props get passed into React components
class Hello extends Component {
render() {
return <h1>Hi, {this.props.name}</h1>
}
}
Seems simple, right?
By default, "props" is available through the this
keyword of your component. They are also able to be passed between your components, generally from parent to child.
Checkout this blog post for a few different examples of props.
Top comments (0)