Created
July 4, 2014 16:57
-
-
Save joecritch/586a6868874c99fa92eb to your computer and use it in GitHub Desktop.
[Issue] Passing props through Route components when state changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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