React-native闪屏和反应导航

时间:2017-06-01 20:48:36

标签: 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);

index.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 />;
    }
}

router.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',
});

deckview.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,或者我可以在修复此代码后保留上面的代码吗?感谢。

1 个答案:

答案 0 :(得分:2)

在index.js中

,更改:

import Root from 'config/router';

为:

import { Root } from 'config/router';

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