If you want to pass props on routes to child components by react router? You can’t currently (pre 1.0) do that with React Router. I believe one recommended way is to have wrapper components:
1 2 3 4 5 6 7 8 9 10 11 12 13 | var BaseComponent = React.createClass({ render: function() { return <p>{this.props.text}</p> } }); var FancyComponent = React.createClass({ return <BaseComponent text="fancy!" /> }); var EvenFancierComponent = React.createClass({ return <BaseComponent text="SUPER fancy!" /> }); |
Then these routes:
1 2 3 | <Route name="standard" handler={BaseComponent} /> <Route name="fancy" handler={FancyComponent} /> <Route name="superfancy" handler={EvenFancierComponent} /> |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.