我最近几天一直在想这个
null is not an object
React native 0.58
应用程序。
应用程序所做的是在
navigator
. 所有代码都包含在
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"
},