【问题标题】:ExNavigation throws an error saying initialRoute is not definedExNavigation 抛出错误,提示未定义 initialRoute
【发布时间】:2017-03-18 15:35:37
【问题描述】:

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

【问题讨论】:

    标签: javascript reactjs react-native exponentjs


    【解决方案1】:

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

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

    它是initialRoute 而不是intitialRoute

    【讨论】:

    • 什么鬼!我不知道这是由于睡眠不足还是避免复制+粘贴“有时”是个坏主意。谢谢!
    猜你喜欢
    • 2021-11-28
    • 2019-05-06
    • 2014-05-30
    • 2014-07-09
    • 2018-11-15
    • 2019-04-19
    • 2016-12-14
    • 2016-02-11
    相关资源
    最近更新 更多