登录屏幕使用React Native堆栈导航器加载两次

时间:2019-02-18 21:49:57

标签: reactjs react-native stack-navigator

我在React Native应用程序中使用堆栈导航器。当我在首次加载时启动应用程序时,登录屏幕似乎总是加载/刷新两次。有人根据我的导航器设置方式知道原因吗?

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

// components
import NavBar from '../../components/nav/NavBar';

// screens
import Welcome from '../../components/screens/Welcome';
import Login from '../../components/screens/Authentication';
import Products from '../../components/screens/Products';
import Product from '../../components/screens/Product';
import RequiresAuth from 'app/helpers/requiresAuth';
import SafeAreaView from 'app/helpers/safeAreaView';

const Root = new StackNavigator({
  Main: {
    screen: new StackNavigator({
      Welcome: {
        screen: SafeAreaView(Welcome),
        navigationOptions: {
          header: null
        }
      },
      Login: {
        screen: SafeAreaView(Login),
        navigationOptions: {
          header: null
        }
      },
      Products: {
        key: 'Products',
        screen:
        SafeAreaView(RequiresAuth(Products)
        ),
        navigationOptions: {
          header: <StatusBar />
        }
      },
      Product: {
        screen: SafeAreaView(RequiresAuth(Product)),
        navigationOptions: {
          header: <StatusBar />
        }
      }
    })
  },
}, {
  mode: 'modal',
  initialRouteName: 'Main'
});

export default Root;

0 个答案:

没有答案