我正在尝试在我的 react-native 中使用 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'
}]
});
我的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() 中加载选项卡进行了非常测试,并且我也尝试只加载一个屏幕。
关于闪屏后崩溃/关闭原因的任何想法?
谢谢。