Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[Issue] Passing props through Route components when state changes
var React = require('react');
var Router = require('react-nested-router');
var Route = Router.Route;
var Sub = React.createClass({
render: function() {
console.log(this.props.myData);
return React.DOM.span(null, 'Should this.props.myData be changing?');
}
});
var Layout = React.createClass({
render: function() {
return React.DOM.div(null, this.props.activeRoute);
}
});
var App = React.createClass({
getInitialState: function() {
return {
myData: ['One']
};
},
componentDidMount: function() {
setTimeout(function() {
console.log('setting myData state...')
this.setState({
myData: ['One', 'two', 'three']
});
}.bind(this), 500);
},
render: function() {
return (
Route({
handler: Layout
},
Route({
handler: Sub,
myData: this.state.myData
})
)
);
}
});
React.renderComponent(App(), document.body);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.