Skip to content

Instantly share code, notes, and snippets.

@rBurgett
Created July 4, 2016 17:02
Show Gist options
  • Save rBurgett/8ed7cf06b7aa12285d4d2b9e6a45a182 to your computer and use it in GitHub Desktop.
Save rBurgett/8ed7cf06b7aa12285d4d2b9e6a45a182 to your computer and use it in GitHub Desktop.
// changes to APP.js
var APP = React.createClass({
...
render() {
return (
<div>
<Header title={this.state.title} status={this.state.status}/>
{/*
The thing with React Router is that it only passes props into its children.
This makes sense for applications with stateless components using Redux
as the data store. But if you want to pass down state, you need to explicitly
add the state data to the children. When I add the title property from state
here, you can now access it through this.props.title in the child component.
*/}
{React.cloneElement(this.props.children, {title: this.state.title})}
</div>
)
}
});
@wesbasinger
Copy link

Very astute, got me past that hurdle. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment