Javascript 将react native与expo+;redux+;前导航
index.jsJavascript 将react native与expo+;redux+;前导航,javascript,react-native,react-native-android,expo,ex-navigation,Javascript,React Native,React Native Android,Expo,Ex Navigation,index.js import React, { Component } from 'react'; import { StatusBar } from 'react-native'; import { Provider, connect } from 'react-redux'; import { NavigationProvider, StackNavigation, NavigationContext } from '@expo/ex-navigation'; import Router
import React, { Component } from 'react';
import { StatusBar } from 'react-native';
import { Provider, connect } from 'react-redux';
import { NavigationProvider, StackNavigation, NavigationContext } from '@expo/ex-navigation';
import Router from './routers';
import Store from './store/configureStore';
// Store & Router
const navigationContext = new NavigationContext({
router: Router,
store: Store,
})
export default class App extends Component {
render() {
return (
<Provider store={Store}>
<NavigationProvider context={navigationContext}>
<StatusBar barStyle="light-content" />
<StackNavigation initialRoute={Router.getRoute('about')} />
</NavigationProvider>
</Provider>
);
}
}
路由器/index.js
import React from 'react';
import { createRouter } from '@expo/ex-navigation';
import About from './About';
export default createRouter(() => ({
about: () => About,
}));
在android avd上运行上述代码时,avd将抛出一个错误:
TypeError:undefined不是对象(正在评估“navigationState.navigators”)
详细错误如下:
TypeError: undefined is not an object (evaluating 'navigationState.navigators')
This error is located at:
in Connect(FocusableComponent(ExNavigationStack)) (at ExNavigationConnect.js:42)
in ExNavConnect (at ExNavigationComponents.js:114)
in ExNavigatorComponent(ExNavigatorComponent) (at index.js:23)
in RCTView (at View.js:113)
in View (at ExNavigationProvider.js:74)
in ExNavigationProvider (at index.js:21)
in Provider (at index.js:20)
in App (at App.js:7)
in App (created by AwakeInDevApp)
in RCTView (at View.js:113)
in View (created by AwakeInDevApp)
in AwakeInDevApp (at registerRootComponent.js:34)
in RootErrorBoundary (at registerRootComponent.js:33)
in ExpoRootComponent (at renderApplication.js:35)
in RCTView (at View.js:113)
in View (at AppContainer.js:102)
in RCTView (at View.js:113)
in View (at AppContainer.js:122)
in AppContainer (at renderApplication.js:34)
- node_modules/@expo/ex-navigation/src/ExNavigationComponents.js:33:20 in getStateForNavigatorId
运行时环境:
- Android仿真器谷歌像素XL
- sdk版本27
- 反应本机:0.50.3
- 反应:16.0.0
- @世博会/ex导航:4.2.0
- 世博会:23.0.6
TypeError: undefined is not an object (evaluating 'navigationState.navigators')
This error is located at:
in Connect(FocusableComponent(ExNavigationStack)) (at ExNavigationConnect.js:42)
in ExNavConnect (at ExNavigationComponents.js:114)
in ExNavigatorComponent(ExNavigatorComponent) (at index.js:23)
in RCTView (at View.js:113)
in View (at ExNavigationProvider.js:74)
in ExNavigationProvider (at index.js:21)
in Provider (at index.js:20)
in App (at App.js:7)
in App (created by AwakeInDevApp)
in RCTView (at View.js:113)
in View (created by AwakeInDevApp)
in AwakeInDevApp (at registerRootComponent.js:34)
in RootErrorBoundary (at registerRootComponent.js:33)
in ExpoRootComponent (at renderApplication.js:35)
in RCTView (at View.js:113)
in View (at AppContainer.js:102)
in RCTView (at View.js:113)
in View (at AppContainer.js:122)
in AppContainer (at renderApplication.js:34)
- node_modules/@expo/ex-navigation/src/ExNavigationComponents.js:33:20 in getStateForNavigatorId