Last active
November 2, 2021 06:21
-
-
Save omeileo/baacf11e44adcdfa14d392670a62f955 to your computer and use it in GitHub Desktop.
Get Previous Scene: React native router flux (4.0.0-beta.28)
This file contains 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
import { Actions } from 'react-native-router-flux' | |
export function getPreviousScene (jumpCount = 1) { // if nothing is passed, it defaults to 1 | |
const index = Actions.prevState.routes.length - (jumpCount + 1) // because zero-based index | |
if (index >= 0) { | |
return Actions.prevState.routes[index].routeName | |
} | |
return 'home' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I used this approach because the provided
prevScene
erroneously returned the current scene for me.