此导航器3缺少导航Prop

问题描述 投票:1回答:1

此导航器缺少导航Prop。在react-navigation 3中,您必须更直接地设置导航。我看了一下有关这方面的文档,但我仍然无法弄清楚如何将其实现到我的代码中。我做错了什么,我将如何解决它。请提供一些帮助。

这是我的RootStack.js

import React from 'react';
import { createStackNavigator, createSwitchNavigator } from 'react-navigation';
import SignInScreen from './App/screens/SignInScreen';
import Account from './App/screens/Account';
import Inventory from './App/screens/Inventory';
import Settings from './App/screens/Settings';
import SignUp from './App/screens/SignUp';
import ForgotScreen from './App/screens/ForgotScreen';
import Tournament from './App/screens/Tournament';
import TournamentRsvp from './App/screens/TournamentRsvp';
import Shop from './App/screens/Shop';
import Game from './App/screens/Game';

const routes = {
  SignInScreen: {
    screen: SignInScreen
  },
  Account: {
    screen: Account
  },
  Tournament: {
    screen: Tournament
  },
  TournamentRsvp: {
    screen: TournamentRsvp
  },
  Shop: {
    screen: Shop
  },
  Game: {
    screen: Game
  },
  SignUp: {
    screen: SignUp
  },
  ForgotScreen: {
    screen: ForgotScreen
  },
  Settings: {
    screen: Settings
  },
  Inventory: {
    screen: Inventory
  }
};

class AuthLoadingScreen extends React.Component {
  constructor() {
    super();
  }
}

const AppStack = createStackNavigator(routes, {
  headerMode: 'none',
  navigationOptions: {
    headerVisible: false
  },
  initialRouteName: 'SignInScreen'
});
const AuthStack = createStackNavigator(
  {
    SignInScreen: {
      screen: SignInScreen
    }
  },
  {
    headerMode: 'none',
    navigationOptions: {
      headerVisible: false
    }
  }
);

export default createSwitchNavigator(
  {
    AuthLoading: AppStack,
    App: AppStack,
    Auth: AuthStack
    // AuthLoading: AppStack,
    // Auth: AuthStack
  },
  {
    initialRouteName: 'AuthLoading'
  }
);

这是我下面的App.js

import React from 'react';
import { Platform, StatusBar, StyleSheet, View } from 'react-native';
import { AppLoading, Asset, Font, Icon } from 'expo';
import * as firebase from 'firebase';
import { createStackNavigator, createSwitchNavigator } from 'react-navigation';
import { firebaseConfig } from './config.js';
import RootStack from './RootStack';

firebase.initializeApp(firebaseConfig);

export default class App extends React.Component {
  render() {
    return (
      <View style={{ flex: 1 }}>
        <RootStack />
      </View>
    );
  }
}

enter image description here

ios react-native react-redux react-router react-navigation
1个回答
0
投票

尝试换入createAppContainer。

import { createAppContainer, createStackNavigator } from 'react-navigation';

export default createAppContainer(createSwitchNavigator(
  {
    AuthLoading: AppStack,
    App: AppStack,
    Auth: AuthStack
    // AuthLoading: AppStack,
    // Auth: AuthStack
  },
  {
    initialRouteName: 'AuthLoading'
  }
));
© www.soinside.com 2019 - 2024. All rights reserved.