嗨,我是Expo的新手,但是我一直很难尝试运行我的代码。即使遇到问题,我也会遇到错误:You must specify initialRoute or initialStack to initialize this StackNavigation

这是我的main.js

import Expo from 'expo'
import React from 'react'
import { createStore } from 'redux'
import { Provider } from 'react-redux'
import {
  NavigationProvider,
  StackNavigation,
} from '@expo/ex-navigation'
import RootReducer from './src/reducers'
import Router from './src/navigation/Router'

const store = createStore(RootReducer)

const App = () => (
  <Provider store={store}>
    <NavigationProvider router={Router}>
      <StackNavigation intitialRoute={Router.getRoute('splash')} />
    </NavigationProvider>
  </Provider>
)

Expo.registerRootComponent(App)


这是我的Router.js

import { createRouter } from '@expo/ex-navigation'

// Screens
import SplashScreen from '../screens/SplashScreen'
import LoginScreen from '../screens/LoginScreen'

const Router = createRouter(() => ({
  splash: () => SplashScreen,
  login: () => LoginScreen,
}))

export default Router


我的设置似乎是什么问题?我只是按照ExNavigation上的示例进行操作。

这是我在Sketch上的示例,但无法使其运行,但将保留完整代码的链接。

最佳答案

您在代码的这一部分中输入了道具名称的错字

<StackNavigation intitialRoute={Router.getRoute('splash')} />


它是initialRoute而不是intitialRoute

关于javascript - ExNavigation引发错误,指出未定义initialRoute,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42876284/

10-11 11:40