我想將一些道具傳遞給IndexRoute上的組件。下面是我的代碼片段:如何通過道具使用react-router通過路由來反應組件?
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>
)
初始加載我能夠加載第一步爲孩子,但我想從路由部分組件通過一些道具。
我怎樣才能得到這個?
請指導我。
感謝, 維傑