I have been rubbing my head last few days about this null is not an object
error for a simple React native 0.58
app.
What the app does is to load a test screen within navigator
. All code is contained in App.js
. Here is the 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);
The project was created with react-native init myproj
and here is the index.js
which I did not change:
/**
* @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);
The react-native-gesture-handler
has been installed and here is the 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"
},