В последние несколько дней я потирал голову об этой null is not an object
ошибке для простого React native 0.58
приложения.
Приложение загружает тестовый экран в пределах 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"
},