[英]Issue with starting a new React-Native project
I'm starting a new project in React Native, and I'm running it with Expo Go on my phone.我正在 React Native 中启动一个新项目,并在我的手机上使用 Expo Go 运行它。 I only have two files, "App.js" and "SearchScreen.js".我只有两个文件,“App.js”和“SearchScreen.js”。 Every time I go to run the code I have in Expo Go, it successfully bundles, and then the app crashes (so I don't see an error, or know what my error is).每次我 go 运行我在 Expo Go 中的代码时,它成功捆绑,然后应用程序崩溃了(所以我没有看到错误)。 I know it's not a problem with Expo Go because when I run the default code that comes with a blank react native app, it loads and functions correctly.我知道 Expo Go 没有问题,因为当我运行空白反应原生应用程序附带的默认代码时,它会正确加载和运行。 The code in App.js and SearchScreen.js comes from a class that's a couple of years old, and I suspect that my problem may relate to that. App.js 和 SearchScreen.js 中的代码来自几年前的 class,我怀疑我的问题可能与此有关。
Because there's no error message, I'm not sure how to proceed.因为没有错误消息,我不知道如何继续。 Does anyone know a solution to this?有谁知道解决这个问题?
Thanks in advance.提前致谢。
App.js:应用程序.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: 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;
I ran "expo install react-native-gesture-handler" and that fixed the problem for me.我运行了“expo install react-native-gesture-handler”,这为我解决了这个问题。 I was getting messages such as "export 'ComposedGestureType' (reexported as 'ComposedGesture') was not found in './handlers/gestures/gestureComposition'" and ""export 'ExclusiveGestureType' (reexported as 'ExclusiveGesture') was not found in './handlers/gestures/gestureComposition'" when running my program on web. Now it's working on my phone again.我收到诸如“在'./handlers/gestures/gestureComposition'中找不到导出'ComposedGestureType'(重新导出为'ComposedGesture')和“导出'ExclusiveGestureType'(重新导出为'ExclusiveGesture')之类的消息'./handlers/gestures/gestureComposition'" 在 web 上运行我的程序时。现在它又可以在我的手机上运行了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.