启动画面

时间:2017-04-02 06:51:29

标签: react-native react-native-navigation

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

我的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'
  }]
});

my 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);
}

my 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()中标签加载方式的测试,我也试图只加载一个屏幕。

关于启动画面后崩溃/关闭原因的任何想法?

感谢。

1 个答案:

答案 0 :(得分:2)