2

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.

enter image description here

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"
  },
user938363
  • 9,990
  • 38
  • 137
  • 303
  • 1
    Try: 1. remove node-modules folder + package-lock.json file. 2. delete this line of code from your dependencies "react-native-gesture-handler": "^1.1.0", 3. yarn install // not npm install. 4. yarn install react-native-gesture-handler – Hend El-Sahli Mar 18 '19 at 23:28
  • 5. > react-native link // for packages that requires linking – Hend El-Sahli Mar 18 '19 at 23:38
  • No luck. I ended up re-installing the whole system (with yarn). But the error stays the same. The error should be related to react-navigation which I don't quite understand. – user938363 Mar 19 '19 at 06:19
  • I'm pretty sure this error has to do with linking, I saw it before. what I usually do in such cases is that I create a brand new project with react-native init , and then I install my packages one-by-one and then exec react-native run-ios after each package to determine the cause of the error. from what I saw so far, linking-related-errors is sooo tricky to understand ... and this is the only way I know so sar to figure it out – Hend El-Sahli Mar 19 '19 at 06:27
  • you may also need to write just an import statement of the package you installed during the step of ((one-by-one package installation and testing)) – Hend El-Sahli Mar 19 '19 at 06:30
  • 1
    `Hend El-Sahli`, Got it on 2nd try with `react-native run-android` after `react-native link`. It is something related to link which I didn't use before. But found an interesting post https://stackoverflow.com/questions/49874385/the-use-of-react-native-link-command. Is the problem caused by missing some native dependencies? Many thanks. – user938363 Mar 19 '19 at 08:25
  • 1
    I will vote up if you summarize in an answer. The problem was so tricky and I have spent a few days on it. – user938363 Mar 19 '19 at 08:31
  • Glad it helps really ... and yes I'd summarize our end result for future reference, Have a great day! – Hend El-Sahli Mar 19 '19 at 08:47

0 Answers0