【问题标题】:Uncaught Error: Invariant Violation & Screen Orientation未捕获的错误:不变违规和屏幕方向
【发布时间】:2019-10-29 02:28:48
【问题描述】:

我对 React / React Native 有点陌生,从以前版本的 Expo 更新项目后,我一直遇到奇怪的“未捕获错误”,似乎是 Expo 的屏幕方向,导致应用无法加载。

根据 Expo 的文档(如下所列),我试图重写应用程序在加载时强制执行特定屏幕方向的方式,但我一直遇到错误。

https://docs.expo.io/versions/latest/sdk/screen-orientation/#screenorientationallowasyncorientationlock

ScreenOrientation.lockAsync(ScreenOrientation.Orientation.LANDSCAPE);
    if (!this.state.isReady) {
      return <Expo.AppLoading />;
    }

ScreenOrientation.lockAsync(ScreenOrientation.Orientation.LANDSCAPE_LEFT);
    return (

最初,应用程序以横向加载并锁定,但现在该应用程序因“不变违规”错误而停滞不前。要查看正在生成的错误的屏幕截图,请查看下面的链接。

https://imgur.com/a/Uw4fnCI

【问题讨论】:

    标签: javascript android react-native expo screen-orientation


    【解决方案1】:

    检查您的导入是否正确。

    import * as ScreenOrientation from 'expo-screen-orientation';
    

    而不是

    import {ScreenOrientation} from 'expo-screen-orientation';
    

    【讨论】:

      猜你喜欢
      • 2015-06-09
      • 1970-01-01
      • 2021-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多