-
-
Save jason-shen/ea4e953079c33d681ad8d91d8d0fa295 to your computer and use it in GitHub Desktop.
React-Navigation for know if the root screen. Let us manages back button android.
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
// @flow | |
export function isRootScreen(navigator: { | |
index: ?number, | |
routes: ?Array<Object>, | |
}) { | |
if (navigator.index == null) { | |
return true; | |
} | |
if (navigator.index > 0) { | |
return false; | |
} | |
return ( | |
!navigator.routes || !navigator.routes.find(route => !isRootScreen(route)) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment