Skip to content

Instantly share code, notes, and snippets.

@Ribeiro-Tiago
Last active February 4, 2019 16:19
Show Gist options
  • Save Ribeiro-Tiago/d637be606a7ff4f2f077850450af2948 to your computer and use it in GitHub Desktop.
Save Ribeiro-Tiago/d637be606a7ff4f2f077850450af2948 to your computer and use it in GitHub Desktop.
const prevGetStateForAction = myStack.router.getStateForAction;
myStack.router.getStateForAction = (action, state) => {
if (state && action.type === "Navigation/NAVIGATE") {
let routes = state.routes;
const lastScene: NavigationRoute = routes.slice(-1)[0];
const lastSceneName = lastScene.routeName;
routes = routes.filter((item: NavigationRoute, index: number) => item.routeName !== lastSceneName);
routes.push(lastScene);
return {
...state,
index: routes.length - 1,
routes
};
}
return prevGetStateForAction(action, state);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment