我是否必须将组件传递到堆栈导航器?

时间:2019-03-15 16:17:54

标签: reactjs react-native

我正在做一个简单的聊天React Native(0.59)应用程序以用于练习。但是App.js不断抛出Null is not an object错误。然后我注释掉了所有组件,只剩下一个createStackNavigator和createAppContainer。这是App.js

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

import codePush from "react-native-code-push";
import Chat from './src/components/Chat';
import Event from './src/components/Event';
import { createStackNavigator, createAppContainer } from 'react-navigation';

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

//create the navigator
const navigator = createStackNavigator({
  //Event: { screen: Event },
  //Chat: { screen: Chat },
});

//export it as the root component
export default createAppContainer(navigator); 

仍然存在

错误
Requiring module "App.js", which threw an exception: TypeError: Properties can only be defined on Objects`

这里缺少什么?

这里是index.js

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

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

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

0 个答案:

没有答案
相关问题