react-native - 简单的 react native 应用程序(使用 react native 导航)在闪屏后崩溃

标签 react-native react-native-navigation

我正在尝试使用react-native-navigation作为我的react-native中的导航系统。我编写了一个非常简单的应用程序来测试它,但是该应用程序在启动屏幕后崩溃(没有给我任何错误或信息)。

我的index.ios.js:

/* eslint-disable no-unused-vars */
import App from './src/app';

我的app.ios.js:

import {
  Platform
} from 'react-native';
import {Navigation} from 'react-native-navigation';

import { registerScreens } from './screens';
registerScreens(); // this is where you register all of your app's screens

// this will start our app
Navigation.startTabBasedApp({
  tabs: [{
    label: 'One',
    screen: 'AwesomeProject.Home', // this is a registered name for a screen
    icon: require('../img/one.png'),
    selectedIcon: require('../img/one_selected.png'), // iOS only
    title: 'Screen One'
  }]
});

我的screens.js

import { Navigation } from 'react-native-navigation';

import Home from './containers/Home';
import About from './containers/About';

// register all screens of the app (including internal ones)
export function registerScreens() {
  Navigation.registerComponent('AwesomeProject.Home', () => Home);
  Navigation.registerComponent('AwesomeProject.About', () => About);
}

我的 Home.js:

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

class Home extends Component {
  render() {
    return (
      <Text>Home!</Text>
    );
  }
}

export default Home;

我的 About.js:

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

class About extends Component {
  render() {
    return (
      <Text>About!</Text>
    );
  }
}

export default About;

您可以在此处查看完整要点:https://gist.github.com/inchr/d0184f4ae91abd6036a2fa61725744c9

我已经对如何在 startTabBasedApp() 中加载选项卡进行了非常多的测试,并且我也尝试过仅加载屏幕。

关于闪屏后崩溃/关闭的原因有什么想法吗?

谢谢。

最佳答案

关于react-native - 简单的 react native 应用程序(使用 react native 导航)在闪屏后崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43165439/

相关文章:

react-native - React Native List View - 在不呈现整个列表的情况下添加项目

react-native - 需要主分支的 react native 功能

android - 在平板电脑等大型设备上始终显示侧边菜单(抽屉)[react-native-navigation]

reactjs - 如何在 React-Native 中渲染 svg 图像?

reactjs - 在自己的函数中响应导航 onPress

android - Firebase 云消息传递 : How to set the notification icon on android?

react-native - 列表项头像不显示

ios - Javascript/ native 代码不同步(不同数量的参数)错误

javascript - Firebase 有时连接,有时不连接(React Native)

react-native-navigation - 如何使用 react native navigation v2 添加侧边栏抽屉?