Skip to content

Instantly share code, notes, and snippets.

@omeileo
Last active November 2, 2021 06:21
Show Gist options
  • Save omeileo/baacf11e44adcdfa14d392670a62f955 to your computer and use it in GitHub Desktop.
Save omeileo/baacf11e44adcdfa14d392670a62f955 to your computer and use it in GitHub Desktop.
Get Previous Scene: React native router flux (4.0.0-beta.28)
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'
}
@omeileo
Copy link
Author

omeileo commented Apr 29, 2019

I used this approach because the provided prevScene erroneously returned the current scene for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment