这有效:
const Router = connect()(Router);
// --- your exported main router
export default class MyExportedRouter extends React.Component {
constructor(props) {
super(props);
};
render() {
return (
<Provider store={store}>
<Router scenes={scenes} />
</Provider>
);
}
}
但如果我改变
const Router = connect()(Router);
...
<Router scenes={scenes} />
...
到
const myConnectedRouter = connect()(Router);
...
<myConnectedRouter scenes={scenes} />
...
失败并出现以下错误:
寻找一个类组件,获取一个对象对象
我的完整代码在这里: https://github.com/aksonov/react-native-router-flux/blob/master/docs/REDUX_FLUX.md
答案 0 :(得分:0)
myConnectedRouter
应该大写,如MyConnectedRouter
connect()
返回'更高阶React组件类'(https://github.com/reactjs/react-redux/blob/master/docs/api.md#connectmapstatetoprops-mapdispatchtoprops-mergeprops-options)
React组件必须大写(https://facebook.github.io/react/docs/jsx-in-depth.html#html-tags-vs.-react-components)
此问题已在ReactJS的上下文中解决:https://stackoverflow.com/a/30373505/1905712