Skip to content

Instantly share code, notes, and snippets.

@joecritch
Created July 4, 2014 16:57
Show Gist options
  • Save joecritch/586a6868874c99fa92eb to your computer and use it in GitHub Desktop.
Save joecritch/586a6868874c99fa92eb to your computer and use it in GitHub Desktop.
[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