UNPKG

504 BJavaScriptView Raw
1import * as React from 'react';
2import NavigationRouteContext from './NavigationRouteContext';
3
4/**
5 * Hook to access the route prop of the parent screen anywhere.
6 *
7 * @returns Route prop of the parent screen.
8 */
9export default function useRoute() {
10 const route = React.useContext(NavigationRouteContext);
11
12 if (route === undefined) {
13 throw new Error("Couldn't find a route object. Is your component inside a screen in a navigator?");
14 }
15
16 return route;
17}
18//# sourceMappingURL=useRoute.js.map
\No newline at end of file