Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Basic React Prop Passing Example
// <Mother /> is a container component that holds the
// application's state.
// In this case, <Mother /> holds the family's lastName.
class Mother extends React.Component {
state = {
lastName: 'Sanchez'
}
render () {
// Mother passes the lastName down one
// level to the <Child />
<Child lastName={this.state.lastName} />
}
}
// <Child /> is a presentational component that
// displays the lastName.
const Child = ({ lastName }) => <p>{lastName}>/p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment