2017-12-29 18 views
1

Back 단추 논리가 스택의 화면 순서를 보는 것으로 나타났습니다. 스택 네비게이터 안에 서랍 탐색기가 있습니다.스택 탐색기에서 화면 제거

스택 맨 위에 스플래시 화면이 있습니다. 대시 보드에서 뒤로 버튼을 누르면 스플래시 화면으로 이동합니다.

앱에 입력 한 후 스플래시 화면을 스택에서 제거 할 수있는 방법은 무엇입니까? 그렇다면 스플래시 화면으로 돌아가는 대신 앱을 종료하는 버튼 대시 보드를 누르면됩니다.

/* @flow */ 

import React from "react"; 
import { Platform, Text } from "react-native"; 
import { Root } from "native-base"; 
import { StackNavigator, DrawerNavigator} from "react-navigation"; 
import Register from "./components/Register"; 
import Available from "./components/Available"; 
import Splash from "./components/splash/“; 
import SideBar from "./components/sidebar"; 
import Discover from "./components/Discover/"; 
import Dashboard from "./components/Dashboard/"; 
import Contact from "./components/Contact" 



const Drawer = DrawerNavigator(
    { 
    Dashboard: { screen: Dashboard }, 
    Discover: { screen: Discover }, 
    Contact: { screen: Contact}, 
     }, 
    { 
    navigationOptions: { 
     gesturesEnabled: false, 
    }, 
    initialRouteName: "Dashboard", 
    contentOptions: { 
     activeTintColor: "#e91e63" 
    }, 
    drawerPosition: 'right', 
    contentComponent: props => <SideBar {...props} /> 
    } 
); 


const AppNavigator = StackNavigator(
    { 
     Splash: { screen: Splash }, 
     Drawer: { screen: Drawer },       
     Available: { screen: Available }, 
     Register: { screen: Register }, 
    }, 
    { 
     // initialRouteName: “Splash”, 
     headerMode: "none", 
    } 
); 

export default() => 
    <Root> 
     <AppNavigator /> 
    </Root>; 
+0

에서 가져옵니다. 감사. – devedv

답변

0

하나의 해결책은 시작 화면 구성 요소 내부의 스택을 재설정하고 사용자가 원하는 화면으로 사용자를 리디렉션하는 것입니다 :

import { NavigationActions } from 'react-navigation' 

const resetAction = NavigationActions.reset({ 
    index: 0, 
    actions: [ 
    NavigationActions.navigate({ routeName: 'Drawer'}) 
    ] 
}) 
this.props.navigation.dispatch(resetAction) 

예는 올바른 표시된 react navigation documentation

+0

하지만이 작업을 수행하면 스플래시 화면이 스택에서 제거되지 않습니다. 대시 보드의 뒤로 누를 때 앱을 종료하려면 스플래시 화면이 아닌 다른 화면으로 이동하십시오. – devedv

+0

이 코드는 스플래시 화면이 더 이상 스택의 일부가 될 수 없도록 모든 기록을 지울 것입니다 – Akis

+0

고마워! 그것은 매력처럼 일했습니다. :) – devedv