React Navigation v3在Expo下不起作用

时间:2019-10-01 19:19:11

标签: react-native react-navigation expo

我正在使用expo来管理我的React Native应用程序。当我想在Android设备上加载它时,我正在使用Play Store中的应用程序。一切顺利,直到今天早些时候(01.10),我的Android设备上的客户端应用已从Play商店自动更新。

出了什么问题?

问题是我的代码库使用的是Expo SDK 32.0,但最新的Android客户端应用至少需要您的Expo SDK的版本为33.0。

我所做的就是遵循本指南:https://docs.expo.io/versions/latest/workflow/upgrading-expo-sdk-walkthrough/#sdk-33

一切都进行得很顺利,但并非如此。我的某些包装出现了一些严重问题,事情真的搞砸了。

那么,我下一步打算做什么?

本周我有一个非常重要的演示,我没有时间研究集成问题。首先,我将代码库恢复为原来的样子(Expo SDK 32.0),然后决定从我的应用程序中删除该客户端应用程序Android设备,并通过下载以下APK安装该设备的先前版本:https://apkpure.com/expo/host.exp.exponent/download/103-APK

现在,我可以在设备上加载应用程序了,但是我得到了与导航有关的非常奇怪的错误:

Select DATEDIFF( DAY, Date2, Date1) as diffdate, count(*)
from Table
group by DATEDIFF( DAY, Date2, Date1);

我实现导航的方式如下:

TypeError: TypeError: undefined is not an object (evaluating 'theme.label')

This error is located at:
    in HeaderTitle (at Header.tsx:220)
    in RCTView (at View.js:44)
    in AnimatedComponent (at Header.tsx:531)
    in RCTView (at View.js:44)
    in RCTView (at View.js:44)
    in RCTView (at View.js:44)
    in AnimatedComponent (at react-native-safe-area-view/index.js:163)
    in SafeView (at withOrientation.js:54)
    in withOrientation (at Header.tsx:722)
    in RCTView (at View.js:44)
    in AnimatedComponent (at Header.tsx:714)
    in Header (at withOrientation.js:30)
    in withOrientation (at StackViewLayout.tsx:227)
    in RCTView (at View.js:44)
    in RCTView (at View.js:44)
    in AnimatedComponent (at StackViewCard.tsx:106)
    in RCTView (at View.js:44)
    in AnimatedComponent (at screens.native.js:59)
    in Screen (at StackViewCard.tsx:93)
    in Card (at createPointerEventsContainer.tsx:95)
    in Container (at StackViewLayout.tsx:985)
    in RCTView (at View.js:44)
    in ScreenContainer (at StackViewLayout.tsx:394)
    in RCTView (at View.js:44)
    in AnimatedComponent (at StackViewLayout.tsx:384)
    in Handler (at StackViewLayout.tsx:377)
    in StackViewLayout (at withOrientation.js:30)
    in withOrientation (at StackView.tsx:104)
    in RCTView (at View.js:44)
    in Transitioner (at StackView.tsx:41)
    in StackView (at createNavigator.js:80)
    in Navigator (at createKeyboardAwareNavigator.js:12)
    in KeyboardAwareNavigator (at createAppContainer.js:430)
    in NavigationContainer (at App.js:97)
    in App (at withExpoRoot.js:22)
    in RootErrorBoundary (at withExpoRoot.js:21)
    in ExpoRootComponent (at renderApplication.js:34)
    in RCTView (at View.js:44)
    in RCTView (at View.js:44)
    in AppContainer (at renderApplication.js:33)

This error is located at:
    in NavigationContainer (at App.js:97)
    in App (at withExpoRoot.js:22)
    in RootErrorBoundary (at withExpoRoot.js:21)
    in ExpoRootComponent (at renderApplication.js:34)
    in RCTView (at View.js:44)
    in RCTView (at View.js:44)
    in AppContainer (at renderApplication.js:33)

我不太了解此错误的出处以及如何解决。

更多信息:

  • react-native-cli:2.0.1
  • 本机:0.57.1​​
  • 博览会:2.6.14
  • expo skd:32.0

我还将分享我的 package.json

import { createStackNavigator, createAppContainer } from 'react-navigation';

// .. other imports

const StackNavigator = createStackNavigator({
    // screen definitions
});

export default createAppContainer(StackNavigator);

,当然还有 app.json

{
...
  "dependencies": {
    "expo": "^32.0.0",
    "firebase": "^5.8.0",
    "react": "16.5.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
    "react-native-autocomplete-input": "^3.6.0",
    "react-native-check-box": "^2.1.7",
    "react-native-modal-datetime-picker": "^7.4.2",
    "react-navigation": "^3.0.9"
  },
  "devDependencies": {
    "babel-preset-expo": "^5.0.0"
  },
...
}

我在设备上选择了应该更改屏幕的选项后,立即发生错误。然后导航介入了,我得到了这个错误。

1 个答案:

答案 0 :(得分:0)

Expo不久前发布了SDK 35,并且您知道他们放弃了对旧SDK的支持(在本例中为SDK 31和SDK 32)。

好的,看着您的package.json文件,我没看到问题-实际上,我建议您升级到SDK 35,您可以阅读有关它的所有内容here

关于您的问题,让我们进行升级并为您节省时间,请执行以下操作:

  1. 确保您没有在运行项目或epxo cli活动。
  2. 通过将sdkVersion更改为app.json来编辑35.0.0
  3. 如下编辑您的package.json
    • react-nativehttps://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz
    • expo^35.0.0
    • react16.8.3
    • react-navigation^4.0.6
  4. 运行expo install react-native-gesture-handler react-native-reanimated react-navigation
  5. 删除您的node_modules目录,然后运行npm installyarn install
  6. 运行expo start -c

现在,您可以使用expo install来安装所需的任何expo依赖项,而不必使用旧的npm install,它将为您的项目下载兼容的依赖项

希望这会有所帮助!