尝试设置一个主要的App组件,如果用户被记录,该组件负责显示“登录”屏幕或整个应用程序。
我唯一的疑问是在一个变量中保存connect()&#39的返回值(应该是我想要的HOC)以在主EntryPoint中使用
我出错的是什么?
const MAIN_TABS_OPTIONS = {
tabBarPosition: 'bottom',
swipeEnabled: false,
animationEnabled: false
}
store = createStore(PACKED_REDUCERS, applyMiddleware(thunk, logger));
store.dispatch(registerAuthStateListener())
store.dispatch(fetchWishes())
class _App extends React.Component {
constructor (props) {
super (props)
}
render () {
const { AUTH } = this.props
RealApplication = StackNavigator({
Index: {
screen: TabNavigator({
Home: {
screen: Home
},
Desideri: {
screen: WishesDashboard
}
}, MAIN_TABS_OPTIONS)
}
}, {
initialRouteName: 'Index',
header: null
})
if (AUTH.user)
return <RealApplication />
else
return <Login />
}
}
const App =
connect(
(state) => {
return {
AUTH: state.auth
}
},
(dispatch) => {
return {
registerAuthStateListener: () => dispatch (registerAuthStateListener()),
fetchWishes: () => dispatch (fetchWishes())
}
}
)(_App)
export default class EntryPoint extends React.Component {
constructor () {
super()
}
render () {
return (
<Provider store={store}>
<App />
</Provider>
)
}
}