手势处理程序收到空对象

时间:2019-03-18 23:22:37

标签: react-native react-navigation

最近几天,我为一个简单的null is not an object应用出现的React native 0.58错误一直在摸索。

enter image description here

应用程序要做的是在navigator中加载测试屏幕。所有代码都包含在App.js中。这是App.js

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 * @flow
 * @lint-ignore-every PLATJPYRIG
 */

import { createStackNavigator, createAppContainer } from 'react-navigation';
import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View} from 'react-native';

class HomeScreen extends React.Component {
  render() {
    return (
      <View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}>
        <Text>Home Screen</Text>
      </View>
    );
  }
}
//create the navigator
const navigator = createStackNavigator({
  Event: { 
    screen: HomeScreen 
  }
});

export default createAppContainer(navigator);

该项目是用react-native init myproj创建的,这里是我没有更改的index.js

/**
 * @format
 * @lint-ignore-every PLACOPYRIG
 */

import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';

AppRegistry.registerComponent(appName, () => App);

export default createAppContainer(navigator);  

react-native-gesture-handler已安装,这里是package.json

"dependencies": {
    "moment": "^2.24.0",
    "react": "16.6.3",
    "react-native": "0.58.5",
    "react-native-cli": "^2.0.1",
    "react-native-code-push": "^5.5.2",
    "react-native-device-info": "^0.26.5",
    "react-native-gesture-handler": "^1.1.0",
    "react-native-gifted-chat": "^0.7.2",
    "react-native-i18n": "^2.0.15",
    "react-native-navigation": "^2.12.0",
    "react-navigation": "^3.3.2",
    "socket.io-client": "^2.2.0",
    "socketio-jwt": "^4.5.0"
  },

0 个答案:

没有答案