import { StackActions , NavigationActions , NavigationParams , } from 'react-navigation' ; let navigator ; function setTopLevelNavigator ( ref ) { navigator = ref ; } function navigate ( routeName , params ? ) { navigator . dispatch ( NavigationActions . navigate ( { routeName , params , } ) ) ; } function reset ( routeName ) { const resetAction = StackActions . reset ( { index : 0 , actions : [ NavigationActions . navigate ( { routeName } ) ] , } ) ; navigator . dispatch ( resetAction ) ; } function goBack ( ) { navigator . dispatch ( NavigationActions . back ( ) ) ; } export default { navigate , reset , goBack , setTopLevelNavigator , } ;