【发布时间】:2015-10-16 14:12:49
【问题描述】:
我在新的 react-router 中使用 react-router 和 ES6 将值传递给组件?我使用<Handler name = {this.state.name} /> 现在使用{this.props.children}。如何从组件中的 App 向其传输数据?
如何将 this.state 转移到 react-routes 中:
export default class App extends React.Component{
constructor () {
this.state = { name: 'Username' };
}
render () {
return (
<div>
{this.props.children} // <-- this.state ???
</div>
);
}
};
React.render((
<Router history={HashHistory}>
<Route path="" component={App}>
<Route path="about" component={About} />
</Route>
</Router>
), document.getElementById('app'));
{this.props.children} //
【问题讨论】:
标签: javascript reactjs ecmascript-6 flux react-router