javascript - React-native 启动画面和 react-navigation

标签 javascript android react-native react-navigation

我正在尝试使用上面引用的库之一,react-native-splash-screenreact-navigation .我明白了

error .

代码如下:

index.android.js

import { AppRegistry } from 'react-native';
import App from './app/index';

AppRegistry.registerComponent('RecallNotes', () => App);

索引.js

import React, { Component } from 'react';
import Root from 'config/router';
import { 
  View,
} from 'react-native';
import SplashScreen from 'react-native-smart-splash-screen';


export default class App extends Component {
    componentDidMount () {
     //SplashScreen.close(SplashScreen.animationType.scale, 850, 500)
        SplashScreen.close({
            animationType: SplashScreen.animationType.scale,
            duration: 850,
            delay: 500,
        })
    }

    render() {
        return <Root />;
    }
}

路由器.js

import React from 'react';
import { StackNavigator } from 'react-navigation';

import DeckView from 'screens/deckview';

export const Root = StackNavigator({
    Home: {
        screen: DeckView
    },
},{
    mode: 'modal',
    headerMode: 'none',
});

甲板 View .js

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

 /*
 *  DeckView class
 *  This is the component of the deck image
 */
export default class DeckView extends Component{

    render(){
      return(
        <View> 
            <Text>Welcome to React Native!</Text>
        </View>
      );
    }
}

我的问题是:我是否必须在我的应用程序的整个导航中使用 StackNavigator,或者我可以在修复此代码后保留上面的代码吗?谢谢。

最佳答案

在 index.js 中,更改:

从 'config/router' 导入 Root;

到:

从 'config/router' 导入 { Root };

因为您没有从 router.js 导出默认值

关于javascript - React-native 启动画面和 react-navigation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44316862/

相关文章:

react-native - 你如何在 React Native 中 require() 一个声音文件?

reactjs - 没有可用的安全区域插入值。确保在应用顶部呈现 `<SafeAreaProvider>`。 - 我该如何解决这个错误?

javascript - JQuery Mobile + Phonegap : $. ajax 调用不工作

android - 以编程方式更改 Android 的 EditText 光标指针颜色

android - 使android底部按钮栏仅在我滚动到页面底部时出现

android - 如何在 ionic 3 应用程序中使用 ion-img?

javascript - SliderIOS – 自定义可移动图像

javascript - 使用 Bit.ly API 仅使用 Javascript 来缩小 URL

java - 使用应用程序在 Safari 上获取 "Assertion failed: (anonymous function)"

javascript - 检测 Chrome for iOS 地址栏何时显示