我使用React Router的 React.js应用程序具有以下结构:
var Dashboard = require('./Dashboard');
var Comments = require('./Comments');
var Index = React.createClass({
render: function () {
return (
<div>
<header>Some header</header>
<RouteHandler />
</div>
);
}
});
var routes = (
<Route path="/" handler={Index}>
<Route path="comments" handler={Comments}/>
<DefaultRoute handler={Dashboard}/>
</Route>
);
ReactRouter.run(routes, function (Handler) {
React.render(<Handler/>, document.body);
});
我想将一些属性传递给Comments
组件。
(通常我会这样做<Comments myprop="value" />
)
用React Router做到这一点最简单,正确的方法是什么?
Use the solution like above and this works in v3.2.5.
or