UNPKG

983 BJavaScriptView Raw
1import { NavigationActions, getNavigation } from '@react-navigation/core';
2
3export default function handleServerRequest(Router, pathWithLeadingSlash, query) {
4 const path = pathWithLeadingSlash.slice(1);
5
6 // Get initial action from the URL
7 const navigationAction = Router.getActionForPathAndParams(path, query) || NavigationActions.init();
8
9 // Get state from reducer
10 const navigationState = Router.getStateForAction(navigationAction);
11 // Prepare top-level navigation prop
12 const actionSubscribers = new Set();
13 const navigation = getNavigation(Router, navigationState, () => {}, actionSubscribers, () => ({}), () => navigation);
14 // Get title from active screen options
15 const activeKey = navigationState.routes[navigationState.index].key;
16 const activeChildNavigation = navigation.getChildNavigation(activeKey);
17 const options = Router.getScreenOptions(activeChildNavigation);
18 const title = options.title || options.headerTitle;
19
20 return { navigation, title };
21}
\No newline at end of file