Skip to content

Instantly share code, notes, and snippets.

@giautm
Created May 27, 2017 14:13
Show Gist options
  • Save giautm/afa2b12b2e6c004c5755ef4d10063141 to your computer and use it in GitHub Desktop.
Save giautm/afa2b12b2e6c004c5755ef4d10063141 to your computer and use it in GitHub Desktop.
export const UnauthNavigator = StackNavigator({
Splash: {
screen: SplashScreen,
navigationOptions: {
header: null,
},
},
SignIn: {
screen: SignInScreen,
navigationOptions: (props) => ({
title: 'Đăng nhập',
}),
},
}, {
cardStyle: {
backgroundColor: '#fff',
},
navigationOptions,
mode: 'modal',
});
navigateOnce(UnauthNavigator);
import {
NavigationActions,
} from 'react-navigation';
const navigateOnce = (Navigator) => {
const { getStateForAction } = Navigator.router;
Navigator.router.getStateForAction = (action, state) => {
const { type, routeName } = action;
if (state && state.routes[state.routes.length - 1].routeName == routeName &&
type === NavigationActions.NAVIGATE) {
return null;
}
return getStateForAction(action, state);
};
return Navigator;
};
export default navigateOnce;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment