代码之家  ›  专栏  ›  技术社区  ›  squeekyDave

react native-未定义不是一个对象(正在计算“rngesturehandlermodule.state”)。

  •  2
  • squeekyDave  · 技术社区  · 7 年前

    我得到这个错误,这让我发疯,我甚至不能在react native上启动一个简单的应用程序。我使用的是最基本的例子,有一个新的项目,仍然会抛出这个错误。 我用 反应导航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;
    
    2 回复  |  直到 7 年前
        1
  •  5
  •   Last Breath    7 年前

    海洛

    因为React导航现在取决于手势,所以在安装了React导航库之后,必须安装一个附加的库才能继续。

    从终端在项目内部运行此命令

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

    那就运行这个

    react-native link react-native-gesture-handler

    这些说明在这里解释得很好

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

    对于新的React导航版本

    最好的问候

        2
  •  2
  •   user987339 jbandi    7 年前
    npm install --save react-native-gesture-handler
    react-native link react-native-gesture-handler
    
    推荐文章