我想将一些props传递给 IndexRoute 上的组件。下面是我的代码片段:
render(root: Element) {
const { store, params } = this as any;
ReactDOM.render(
<Provider {...{ store }} >
<Router history={browserHistory}>
<Route path={window.location.pathname} component={App}>
<IndexRoute component={Step1} />
<Route path="step1" component={() => (<Step1 params={params} />)} />
<Route path="step1" component={() => (<Step2 params={params} />)} />
</Route>
</Router>
</Provider>
, root);
}
//App Component
import * as React from 'react';
export var App: any = ({children}) => (
<div>
<div>{children}</div>
</div>
)
在初始加载时,我可以将 step1 作为子项加载,但我想将一些props从路由部分传递到组件。
我怎样才能得到这个?
请指导我。
谢谢,维杰