gpt4 book ai didi

react-native - React Native - undefined 不是对象(评估 'RNGestureHandlerModule.state')

转载 作者:行者123 更新时间:2023-12-01 22:01:37 25 4
gpt4 key购买 nike

我收到这个错误,这让我发疯,我什至无法在 React Native 上启动一个简单的应用程序。我正在使用最基本的示例,使用一个新项目,但仍然会抛出此错误。我使用 react-navigation v3xx有人请帮忙,因为我失去了理智,谢谢。这是我的代码:

import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View, Button, TouchableHighlight} from 'react-native';
import { createAppContainer, createStackNavigator, StackActions, NavigationActions } from 'react-navigation'; // Version can be specified in package.json


class Home extends React.Component {
static navigationOptions = {
title: "Home",
}
render() {
return (
<View style={styles.container}>
<Text>Home Page</Text>
<Button onPress={() => this.props.navigation.navigate('About')} title="All about me" />
</View>
);
}
}

class AboutMeMe extends React.Component {
static navigationOptions = {
title: "All Me",
}
render() {
return (
<View style={styles.container}>
<Text>Home Page</Text>
<Button onPress={() => this.props.navigation.goBack()} title="<< Back" />
</View>
);
}
}

const AppScreens = createStackNavigator({
Home: Home,
About: AboutMeMe
})

const App = createAppContainer(AppScreens);

const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
});


export default App;

最佳答案

你好

由于 react 导航现在依赖于手势,所以你必须在安装 react-navigation 库之后安装一个额外的库

从您的终端在您的项目中运行此命令

npm install --save react-native-gesture-handler

然后运行这个

react-native 链接 react-native-gesture-handler

这些指令在这里有很好的解释

https://reactnavigation.org/docs/en/getting-started.html#installation

对于新的 react 导航版本

最好的问候

关于react-native - React Native - undefined 不是对象(评估 'RNGestureHandlerModule.state'),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53401535/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com