Last active
February 4, 2019 16:19
-
-
Save Ribeiro-Tiago/d637be606a7ff4f2f077850450af2948 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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