Created
August 15, 2017 12:38
-
-
Save EQuimper/f35685f23d895b33fd5917d8841e4081 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