1

嗨,我是 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上的示例,但无法使其运行,但会留下完整代码的链接。

4

1 回答 1

1

在这部分代码中,道具名称有错字

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

initialRoute不是intitialRoute.

于 2017-03-18T18:29:38.797 回答