React Native - undefined 不是对象(评估 'RNGestureHandlerModule.state')
React Native - undefined is not an object(evaluating 'RNGestureHandlerModule.state')
我收到这个错误,这让我抓狂,我什至无法在 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;
npm install --save react-native-gesture-handler
react-native link react-native-gesture-handler
你好
由于 react 导航现在依赖于手势,因此您必须在安装 react-navigation 库后安装一个额外的库
运行 从您的终端在您的项目中执行此命令
npm install --save react-native-gesture-handler
然后运行这个
react-native link react-native-gesture-handler
这些说明在这里有很好的解释
https://reactnavigation.org/docs/en/getting-started.html#installation
对于新的 React 导航版本
此致
我收到这个错误,这让我抓狂,我什至无法在 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;
npm install --save react-native-gesture-handler
react-native link react-native-gesture-handler
你好
由于 react 导航现在依赖于手势,因此您必须在安装 react-navigation 库后安装一个额外的库
运行 从您的终端在您的项目中执行此命令
npm install --save react-native-gesture-handler
然后运行这个
react-native link react-native-gesture-handler
这些说明在这里有很好的解释
https://reactnavigation.org/docs/en/getting-started.html#installation
对于新的 React 导航版本
此致