0
我試圖使用連接到Redux的存儲組件與反應路由器(簡體):如何在反應路由器上使用Redux連接的組件?
export class SomeComponent extends React.Component {
// ... some methods goes here
export default connect(
state => ({
someState: state.someState,
}),
dispatch => bindActionCreators({
someAction,
}, dispatch)
)(SomeComponent);
}
某處,我需要連接的組件與反應路由器:
const routes = (
<Route path='/' component={Layout}>
<Route path='/somepath' component={SomeComponent} />
</Route>
);
export default class Verification extends React.Component {
render() {
const createElement = (Component, props) => {
return (
<Component />
);
};
return (
<div>
<Provider store={store}>
<Router history={browserHistory} createElement={createElement}>
{routes}
</Router>
</Provider>
</div>
);
}
}
它正常工作與組件沒有connect()
,但不幸的是它連接組件失敗,因爲Layout
組件需要Children
,但是Children
未定義。
是否可以通過內聯樣式將組件傳遞給路由器?