【问题标题】:Issue with starting a new React-Native project启动一个新的 React-Native 项目的问题
【发布时间】:2021-12-10 00:41:38
【问题描述】:

我正在使用 React Native 开始一个新项目,并在我的手机上使用 Expo Go 运行它。我只有两个文件,“App.js”和“SearchScreen.js”。每次我去运行我在 Expo Go 中的代码时,它都会成功捆绑,然后应用程序崩溃(所以我没有看到错误,或者知道我的错误是什么)。我知道 Expo Go 没有问题,因为当我运行空白反应原生应用程序附带的默认代码时,它会正确加载和运行。 App.js 和 SearchScreen.js 中的代码来自一个已有几年历史的类,我怀疑我的问题可能与此有关。

因为没有错误消息,我不知道如何继续。有谁知道这个问题的解决方案吗?

提前致谢。

App.js:

import { createAppContainer } from 'react-navigation';
import { createStackNavigator } from 'react-navigation-stack';
import SearchScreen from './src/screens/SearchScreen';

const navigator = createStackNavigator(
  {
    Search: SearchScreen,
  },
  {
    initialRouteName: 'Search',
    defaultNavigationOptions: {
      title: 'Business Search',
    },
  }
);

export default createAppContainer(navigator);

SearchScreen.js:

import React from 'react';
import { View, Text, StyleSheet } from 'react-native';

const SearchScreen = () => {
  return (
    <View>
      <Text>Search Screen</Text>
    </View>
  );
};

const styles = StyleSheet.create({});

export default SearchScreen;

【问题讨论】:

  • 如果你在浏览器中打开网页版呢?
  • 我没有看到这个选项——谢谢,它在我的浏览器上运行正确。我不确定这对使用移动应用程序意味着什么,但我会进一步研究。谢谢!
  • 我运行了“expo install react-native-gesture-handler”,这为我解决了这个问题。我收到诸如“在'./handlers/gestures/gestureComposition'中找不到导出'ComposedGestureType'(重新导出为'ComposedGesture')和“导出'ExclusiveGestureType'(重新导出为'ExclusiveGesture')之类的消息'./handlers/gestures/gestureComposition'"。现在它又可以在我的手机上运行了。
  • 不错。随意将其添加为下面的答案。似乎是一种可以在未来帮助人们的东西

标签: javascript reactjs react-native expo


【解决方案1】:

我运行了expo install react-native-gesture-handler,这为我解决了问题。

在网络上运行我的程序时,我收到如下消息:

  • export 'ComposedGestureType' (reexported as 'ComposedGesture') was not found in './handlers/gestures/gestureComposition'
  • export 'ExclusiveGestureType' (reexported as 'ExclusiveGesture') was not found in './handlers/gestures/gestureComposition'

现在它又可以在我的手机上运行了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-30
    • 1970-01-01
    • 2018-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-01
    • 2020-05-18
    相关资源
    最近更新 更多