@react-navigation/native 6.0.6 → 6.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/lib/commonjs/Link.js +6 -5
  2. package/lib/commonjs/Link.js.map +1 -1
  3. package/lib/commonjs/NavigationContainer.js +9 -8
  4. package/lib/commonjs/NavigationContainer.js.map +1 -1
  5. package/lib/commonjs/ServerContainer.js +5 -4
  6. package/lib/commonjs/ServerContainer.js.map +1 -1
  7. package/lib/commonjs/ServerContext.js.map +1 -1
  8. package/lib/commonjs/index.js +16 -16
  9. package/lib/commonjs/theming/ThemeProvider.js +5 -4
  10. package/lib/commonjs/theming/ThemeProvider.js.map +1 -1
  11. package/lib/commonjs/useDocumentTitle.js +9 -8
  12. package/lib/commonjs/useDocumentTitle.js.map +1 -1
  13. package/lib/commonjs/useLinkProps.js +8 -5
  14. package/lib/commonjs/useLinkProps.js.map +1 -1
  15. package/lib/commonjs/useLinking.js +60 -40
  16. package/lib/commonjs/useLinking.js.map +1 -1
  17. package/lib/commonjs/useLinking.native.js +34 -29
  18. package/lib/commonjs/useLinking.native.js.map +1 -1
  19. package/lib/module/Link.js +6 -5
  20. package/lib/module/Link.js.map +1 -1
  21. package/lib/module/NavigationContainer.js +9 -8
  22. package/lib/module/NavigationContainer.js.map +1 -1
  23. package/lib/module/ServerContainer.js +5 -4
  24. package/lib/module/ServerContainer.js.map +1 -1
  25. package/lib/module/ServerContext.js.map +1 -1
  26. package/lib/module/theming/ThemeProvider.js +5 -4
  27. package/lib/module/theming/ThemeProvider.js.map +1 -1
  28. package/lib/module/useDocumentTitle.js +8 -7
  29. package/lib/module/useDocumentTitle.js.map +1 -1
  30. package/lib/module/useLinkProps.js +8 -5
  31. package/lib/module/useLinkProps.js.map +1 -1
  32. package/lib/module/useLinking.js +57 -38
  33. package/lib/module/useLinking.js.map +1 -1
  34. package/lib/module/useLinking.native.js +33 -28
  35. package/lib/module/useLinking.native.js.map +1 -1
  36. package/package.json +7 -6
  37. package/src/ServerContext.tsx +3 -2
  38. package/src/useLinking.native.tsx +6 -1
  39. package/src/useLinking.tsx +46 -15
@@ -25,11 +25,12 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
25
25
  * @param props.action Optional action to use for in-page navigation. By default, the path is parsed to an action based on linking config.
26
26
  * @param props.children Child elements to render the content.
27
27
  */
28
- function Link({
29
- to,
30
- action,
31
- ...rest
32
- }) {
28
+ function Link(_ref) {
29
+ let {
30
+ to,
31
+ action,
32
+ ...rest
33
+ } = _ref;
33
34
  const props = (0, _useLinkProps.default)({
34
35
  to,
35
36
  action
@@ -1 +1 @@
1
- {"version":3,"sources":["Link.tsx"],"names":["Link","to","action","rest","props","onPress","e","React","createElement","Text","Platform","select","web","onClick","default"],"mappings":";;;;;;;AACA;;AACA;;AAEA;;;;;;;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,IAAT,CAA+D;AAC5EC,EAAAA,EAD4E;AAE5EC,EAAAA,MAF4E;AAG5E,KAAGC;AAHyE,CAA/D,EAIM;AACnB,QAAMC,KAAK,GAAG,2BAAwB;AAAEH,IAAAA,EAAF;AAAMC,IAAAA;AAAN,GAAxB,CAAd;;AAEA,QAAMG,OAAO,GACXC,CADc,IAEX;AACH,QAAI,aAAaH,IAAjB,EAAuB;AAAA;;AACrB,uBAAAA,IAAI,CAACE,OAAL,qEAAAF,IAAI,EAAWG,CAAX,CAAJ;AACD;;AAEDF,IAAAA,KAAK,CAACC,OAAN,CAAcC,CAAd;AACD,GARD;;AAUA,sBAAOC,KAAK,CAACC,aAAN,CAAoBC,iBAApB,EAA0B,EAC/B,GAAGL,KAD4B;AAE/B,OAAGD,IAF4B;AAG/B,OAAGO,sBAASC,MAAT,CAAgB;AACjBC,MAAAA,GAAG,EAAE;AAAEC,QAAAA,OAAO,EAAER;AAAX,OADY;AAEjBS,MAAAA,OAAO,EAAE;AAAET,QAAAA;AAAF;AAFQ,KAAhB;AAH4B,GAA1B,CAAP;AAQD","sourcesContent":["import type { NavigationAction } from '@react-navigation/core';\nimport * as React from 'react';\nimport { GestureResponderEvent, Platform, Text, TextProps } from 'react-native';\n\nimport useLinkProps from './useLinkProps';\nimport type { To } from './useLinkTo';\n\ntype Props<ParamList extends ReactNavigation.RootParamList> = {\n to: To<ParamList>;\n action?: NavigationAction;\n target?: string;\n onPress?: (\n e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent\n ) => void;\n} & (TextProps & { children: React.ReactNode });\n\n/**\n * Component to render link to another screen using a path.\n * Uses an anchor tag on the web.\n *\n * @param props.to Absolute path to screen (e.g. `/feeds/hot`).\n * @param props.action Optional action to use for in-page navigation. By default, the path is parsed to an action based on linking config.\n * @param props.children Child elements to render the content.\n */\nexport default function Link<ParamList extends ReactNavigation.RootParamList>({\n to,\n action,\n ...rest\n}: Props<ParamList>) {\n const props = useLinkProps<ParamList>({ to, action });\n\n const onPress = (\n e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent\n ) => {\n if ('onPress' in rest) {\n rest.onPress?.(e);\n }\n\n props.onPress(e);\n };\n\n return React.createElement(Text, {\n ...props,\n ...rest,\n ...Platform.select({\n web: { onClick: onPress } as any,\n default: { onPress },\n }),\n });\n}\n"]}
1
+ {"version":3,"sources":["Link.tsx"],"names":["Link","to","action","rest","props","onPress","e","React","createElement","Text","Platform","select","web","onClick","default"],"mappings":";;;;;;;AACA;;AACA;;AAEA;;;;;;;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,IAAT,OAIM;AAAA,MAJyD;AAC5EC,IAAAA,EAD4E;AAE5EC,IAAAA,MAF4E;AAG5E,OAAGC;AAHyE,GAIzD;AACnB,QAAMC,KAAK,GAAG,2BAAwB;AAAEH,IAAAA,EAAF;AAAMC,IAAAA;AAAN,GAAxB,CAAd;;AAEA,QAAMG,OAAO,GACXC,CADc,IAEX;AACH,QAAI,aAAaH,IAAjB,EAAuB;AAAA;;AACrB,uBAAAA,IAAI,CAACE,OAAL,qEAAAF,IAAI,EAAWG,CAAX,CAAJ;AACD;;AAEDF,IAAAA,KAAK,CAACC,OAAN,CAAcC,CAAd;AACD,GARD;;AAUA,sBAAOC,KAAK,CAACC,aAAN,CAAoBC,iBAApB,EAA0B,EAC/B,GAAGL,KAD4B;AAE/B,OAAGD,IAF4B;AAG/B,OAAGO,sBAASC,MAAT,CAAgB;AACjBC,MAAAA,GAAG,EAAE;AAAEC,QAAAA,OAAO,EAAER;AAAX,OADY;AAEjBS,MAAAA,OAAO,EAAE;AAAET,QAAAA;AAAF;AAFQ,KAAhB;AAH4B,GAA1B,CAAP;AAQD","sourcesContent":["import type { NavigationAction } from '@react-navigation/core';\nimport * as React from 'react';\nimport { GestureResponderEvent, Platform, Text, TextProps } from 'react-native';\n\nimport useLinkProps from './useLinkProps';\nimport type { To } from './useLinkTo';\n\ntype Props<ParamList extends ReactNavigation.RootParamList> = {\n to: To<ParamList>;\n action?: NavigationAction;\n target?: string;\n onPress?: (\n e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent\n ) => void;\n} & (TextProps & { children: React.ReactNode });\n\n/**\n * Component to render link to another screen using a path.\n * Uses an anchor tag on the web.\n *\n * @param props.to Absolute path to screen (e.g. `/feeds/hot`).\n * @param props.action Optional action to use for in-page navigation. By default, the path is parsed to an action based on linking config.\n * @param props.children Child elements to render the content.\n */\nexport default function Link<ParamList extends ReactNavigation.RootParamList>({\n to,\n action,\n ...rest\n}: Props<ParamList>) {\n const props = useLinkProps<ParamList>({ to, action });\n\n const onPress = (\n e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent\n ) => {\n if ('onPress' in rest) {\n rest.onPress?.(e);\n }\n\n props.onPress(e);\n };\n\n return React.createElement(Text, {\n ...props,\n ...rest,\n ...Platform.select({\n web: { onClick: onPress } as any,\n default: { onPress },\n }),\n });\n}\n"]}
@@ -47,14 +47,15 @@ global.REACT_NAVIGATION_DEVTOOLS = new WeakMap();
47
47
  * @param props.children Child elements to render the content.
48
48
  * @param props.ref Ref object which refers to the navigation object containing helper methods.
49
49
  */
50
- function NavigationContainerInner({
51
- theme = _DefaultTheme.default,
52
- linking,
53
- fallback = null,
54
- documentTitle,
55
- onReady,
56
- ...rest
57
- }, ref) {
50
+ function NavigationContainerInner(_ref, ref) {
51
+ let {
52
+ theme = _DefaultTheme.default,
53
+ linking,
54
+ fallback = null,
55
+ documentTitle,
56
+ onReady,
57
+ ...rest
58
+ } = _ref;
58
59
  const isLinkingEnabled = linking ? linking.enabled !== false : false;
59
60
 
60
61
  if (linking !== null && linking !== void 0 && linking.config) {
@@ -1 +1 @@
1
- {"version":3,"sources":["NavigationContainer.tsx"],"names":["global","REACT_NAVIGATION_DEVTOOLS","WeakMap","NavigationContainerInner","theme","DefaultTheme","linking","fallback","documentTitle","onReady","rest","ref","isLinkingEnabled","enabled","config","refContainer","React","useRef","getInitialState","independent","prefixes","useEffect","current","set","getStateFromPath","getPathFromState","getActionFromState","isResolved","initialState","useImperativeHandle","linkingContext","useMemo","options","isReady","onReadyRef","NavigationContainer","forwardRef"],"mappings":";;;;;;;AAAA;;AAUA;;AAEA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;;;AASAA,MAAM,CAACC,yBAAP,GAAmC,IAAIC,OAAJ,EAAnC;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,wBAAT,CACE;AACEC,EAAAA,KAAK,GAAGC,qBADV;AAEEC,EAAAA,OAFF;AAGEC,EAAAA,QAAQ,GAAG,IAHb;AAIEC,EAAAA,aAJF;AAKEC,EAAAA,OALF;AAME,KAAGC;AANL,CADF,EASEC,GATF,EAUE;AACA,QAAMC,gBAAgB,GAAGN,OAAO,GAAGA,OAAO,CAACO,OAAR,KAAoB,KAAvB,GAA+B,KAA/D;;AAEA,MAAIP,OAAJ,aAA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A0BlB,GAA1B,EAA+B,MAAMI,YAAY,CAACO,OAAlD;AAEA,QAAMQ,cAAc,GAAGd,KAAK,CAACe,OAAN,CAAc,OAAO;AAAEC,IAAAA,OAAO,EAAE1B;AAAX,GAAP,CAAd,EAA4C,CAACA,OAAD,CAA5C,CAAvB;AAEA,QAAM2B,OAAO,GAAGvB,IAAI,CAACkB,YAAL,IAAqB,IAArB,IAA6B,CAAChB,gBAA9B,IAAkDe,UAAlE;AAEA,QAAMO,UAAU,GAAGlB,KAAK,CAACC,MAAN,CAAaR,OAAb,CAAnB;AAEAO,EAAAA,KAAK,CAACK,SAAN,CAAgB,MAAM;AACpBa,IAAAA,UAAU,CAACZ,OAAX,GAAqBb,OAArB;AACD,GAFD;AAIAO,EAAAA,KAAK,CAACK,SAAN,CAAgB,MAAM;AACpB,QAAIY,OAAJ,EAAa;AAAA;;AACX,6BAAAC,UAAU,CAACZ,OAAX,iFAAAY,UAAU;AACX;AACF,GAJD,EAIG,CAACD,OAAD,CAJH;;AAMA,MAAI,CAACA,OAAL,EAAc;AACZ;AACA;AACA,WAAO1B,QAAP;AACD;;AAED,sBACE,oBAAC,uBAAD,CAAgB,QAAhB;AAAyB,IAAA,KAAK,EAAEuB;AAAhC,kBACE,oBAAC,sBAAD;AAAe,IAAA,KAAK,EAAE1B;AAAtB,kBACE,oBAAC,6BAAD,eACMM,IADN;AAEE,IAAA,YAAY,EACVA,IAAI,CAACkB,YAAL,IAAqB,IAArB,GAA4BA,YAA5B,GAA2ClB,IAAI,CAACkB,YAHpD;AAKE,IAAA,GAAG,EAAEb;AALP,KADF,CADF,CADF;AAaD;;AAED,MAAMoB,mBAAmB,gBAAGnB,KAAK,CAACoB,UAAN,CAAiBjC,wBAAjB,CAA5B;eAQegC,mB","sourcesContent":["import {\n BaseNavigationContainer,\n getActionFromState,\n getPathFromState,\n getStateFromPath,\n NavigationContainerProps,\n NavigationContainerRef,\n ParamListBase,\n validatePathConfig,\n} from '@react-navigation/core';\nimport * as React from 'react';\n\nimport LinkingContext from './LinkingContext';\nimport DefaultTheme from './theming/DefaultTheme';\nimport ThemeProvider from './theming/ThemeProvider';\nimport type { DocumentTitleOptions, LinkingOptions, Theme } from './types';\nimport useBackButton from './useBackButton';\nimport useDocumentTitle from './useDocumentTitle';\nimport useLinking from './useLinking';\nimport useThenable from './useThenable';\n\ndeclare global {\n var REACT_NAVIGATION_DEVTOOLS: WeakMap<\n NavigationContainerRef<any>,\n { readonly linking: LinkingOptions<any> }\n >;\n}\n\nglobal.REACT_NAVIGATION_DEVTOOLS = new WeakMap();\n\ntype Props<ParamList extends {}> = NavigationContainerProps & {\n theme?: Theme;\n linking?: LinkingOptions<ParamList>;\n fallback?: React.ReactNode;\n documentTitle?: DocumentTitleOptions;\n onReady?: () => void;\n};\n\n/**\n * Container component which holds the navigation state designed for React Native apps.\n * This should be rendered at the root wrapping the whole app.\n *\n * @param props.initialState Initial state object for the navigation tree. When deep link handling is enabled, this will override deep links when specified. Make sure that you don't specify an `initialState` when there's a deep link (`Linking.getInitialURL()`).\n * @param props.onReady Callback which is called after the navigation tree mounts.\n * @param props.onStateChange Callback which is called with the latest navigation state when it changes.\n * @param props.theme Theme object for the navigators.\n * @param props.linking Options for deep linking. Deep link handling is enabled when this prop is provided, unless `linking.enabled` is `false`.\n * @param props.fallback Fallback component to render until we have finished getting initial state when linking is enabled. Defaults to `null`.\n * @param props.documentTitle Options to configure the document title on Web. Updating document title is handled by default unless `documentTitle.enabled` is `false`.\n * @param props.children Child elements to render the content.\n * @param props.ref Ref object which refers to the navigation object containing helper methods.\n */\nfunction NavigationContainerInner(\n {\n theme = DefaultTheme,\n linking,\n fallback = null,\n documentTitle,\n onReady,\n ...rest\n }: Props<ParamListBase>,\n ref?: React.Ref<NavigationContainerRef<ParamListBase> | null>\n) {\n const isLinkingEnabled = linking ? linking.enabled !== false : false;\n\n if (linking?.config) {\n validatePathConfig(linking.config);\n }\n\n const refContainer =\n React.useRef<NavigationContainerRef<ParamListBase>>(null);\n\n useBackButton(refContainer);\n useDocumentTitle(refContainer, documentTitle);\n\n const { getInitialState } = useLinking(refContainer, {\n independent: rest.independent,\n enabled: isLinkingEnabled,\n prefixes: [],\n ...linking,\n });\n\n // Add additional linking related info to the ref\n // This will be used by the devtools\n React.useEffect(() => {\n if (refContainer.current) {\n REACT_NAVIGATION_DEVTOOLS.set(refContainer.current, {\n get linking() {\n return {\n ...linking,\n enabled: isLinkingEnabled,\n prefixes: linking?.prefixes ?? [],\n getStateFromPath: linking?.getStateFromPath ?? getStateFromPath,\n getPathFromState: linking?.getPathFromState ?? getPathFromState,\n getActionFromState:\n linking?.getActionFromState ?? getActionFromState,\n };\n },\n });\n }\n });\n\n const [isResolved, initialState] = useThenable(getInitialState);\n\n React.useImperativeHandle(ref, () => refContainer.current);\n\n const linkingContext = React.useMemo(() => ({ options: linking }), [linking]);\n\n const isReady = rest.initialState != null || !isLinkingEnabled || isResolved;\n\n const onReadyRef = React.useRef(onReady);\n\n React.useEffect(() => {\n onReadyRef.current = onReady;\n });\n\n React.useEffect(() => {\n if (isReady) {\n onReadyRef.current?.();\n }\n }, [isReady]);\n\n if (!isReady) {\n // This is temporary until we have Suspense for data-fetching\n // Then the fallback will be handled by a parent `Suspense` component\n return fallback as React.ReactElement;\n }\n\n return (\n <LinkingContext.Provider value={linkingContext}>\n <ThemeProvider value={theme}>\n <BaseNavigationContainer\n {...rest}\n initialState={\n rest.initialState == null ? initialState : rest.initialState\n }\n ref={refContainer}\n />\n </ThemeProvider>\n </LinkingContext.Provider>\n );\n}\n\nconst NavigationContainer = React.forwardRef(NavigationContainerInner) as <\n RootParamList extends {} = ReactNavigation.RootParamList\n>(\n props: Props<RootParamList> & {\n ref?: React.Ref<NavigationContainerRef<RootParamList>>;\n }\n) => React.ReactElement;\n\nexport default NavigationContainer;\n"]}
1
+ {"version":3,"sources":["NavigationContainer.tsx"],"names":["global","REACT_NAVIGATION_DEVTOOLS","WeakMap","NavigationContainerInner","ref","theme","DefaultTheme","linking","fallback","documentTitle","onReady","rest","isLinkingEnabled","enabled","config","refContainer","React","useRef","getInitialState","independent","prefixes","useEffect","current","set","getStateFromPath","getPathFromState","getActionFromState","isResolved","initialState","useImperativeHandle","linkingContext","useMemo","options","isReady","onReadyRef","NavigationContainer","forwardRef"],"mappings":";;;;;;;AAAA;;AAUA;;AAEA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;;;AASAA,MAAM,CAACC,yBAAP,GAAmC,IAAIC,OAAJ,EAAnC;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,wBAAT,OASEC,GATF,EAUE;AAAA,MATA;AACEC,IAAAA,KAAK,GAAGC,qBADV;AAEEC,IAAAA,OAFF;AAGEC,IAAAA,QAAQ,GAAG,IAHb;AAIEC,IAAAA,aAJF;AAKEC,IAAAA,OALF;AAME,OAAGC;AANL,GASA;AACA,QAAMC,gBAAgB,GAAGL,OAAO,GAAGA,OAAO,CAACM,OAAR,KAAoB,KAAvB,GAA+B,KAA/D;;AAEA,MAAIN,OAAJ,aAAIA,OAAJ,eAAIA,OAAO,CAAEO,MAAb,EAAqB;AACnB,kCAAmBP,OAAO,CAACO,MAA3B;AACD;;AAED,QAAMC,YAAY,GAChBC,KAAK,CAACC,MAAN,CAAoD,IAApD,CADF;AAGA,8BAAcF,YAAd;AACA,iCAAiBA,YAAjB,EAA+BN,aAA/B;AAEA,QAAM;AAAES,IAAAA;AAAF,MAAsB,yBAAWH,YAAX,EAAyB;AACnDI,IAAAA,WAAW,EAAER,IAAI,CAACQ,WADiC;AAEnDN,IAAAA,OAAO,EAAED,gBAF0C;AAGnDQ,IAAAA,QAAQ,EAAE,EAHyC;AAInD,OAAGb;AAJgD,GAAzB,CAA5B,CAbA,CAoBA;AACA;;AACAS,EAAAA,KAAK,CAACK,SAAN,CAAgB,MAAM;AACpB,QAAIN,YAAY,CAACO,OAAjB,EAA0B;AACxBrB,MAAAA,yBAA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AAC,UAAU,CAACZ,OAAX,iFAAAY,UAAU;AACX;AACF,GAJD,EAIG,CAACD,OAAD,CAJH;;AAMA,MAAI,CAACA,OAAL,EAAc;AACZ;AACA;AACA,WAAOzB,QAAP;AACD;;AAED,sBACE,oBAAC,uBAAD,CAAgB,QAAhB;AAAyB,IAAA,KAAK,EAAEsB;AAAhC,kBACE,oBAAC,sBAAD;AAAe,IAAA,KAAK,EAAEzB;AAAtB,kBACE,oBAAC,6BAAD,eACMM,IADN;AAEE,IAAA,YAAY,EACVA,IAAI,CAACiB,YAAL,IAAqB,IAArB,GAA4BA,YAA5B,GAA2CjB,IAAI,CAACiB,YAHpD;AAKE,IAAA,GAAG,EAAEb;AALP,KADF,CADF,CADF;AAaD;;AAED,MAAMoB,mBAAmB,gBAAGnB,KAAK,CAACoB,UAAN,CAAiBjC,wBAAjB,CAA5B;eAQegC,mB","sourcesContent":["import {\n BaseNavigationContainer,\n getActionFromState,\n getPathFromState,\n getStateFromPath,\n NavigationContainerProps,\n NavigationContainerRef,\n ParamListBase,\n validatePathConfig,\n} from '@react-navigation/core';\nimport * as React from 'react';\n\nimport LinkingContext from './LinkingContext';\nimport DefaultTheme from './theming/DefaultTheme';\nimport ThemeProvider from './theming/ThemeProvider';\nimport type { DocumentTitleOptions, LinkingOptions, Theme } from './types';\nimport useBackButton from './useBackButton';\nimport useDocumentTitle from './useDocumentTitle';\nimport useLinking from './useLinking';\nimport useThenable from './useThenable';\n\ndeclare global {\n var REACT_NAVIGATION_DEVTOOLS: WeakMap<\n NavigationContainerRef<any>,\n { readonly linking: LinkingOptions<any> }\n >;\n}\n\nglobal.REACT_NAVIGATION_DEVTOOLS = new WeakMap();\n\ntype Props<ParamList extends {}> = NavigationContainerProps & {\n theme?: Theme;\n linking?: LinkingOptions<ParamList>;\n fallback?: React.ReactNode;\n documentTitle?: DocumentTitleOptions;\n onReady?: () => void;\n};\n\n/**\n * Container component which holds the navigation state designed for React Native apps.\n * This should be rendered at the root wrapping the whole app.\n *\n * @param props.initialState Initial state object for the navigation tree. When deep link handling is enabled, this will override deep links when specified. Make sure that you don't specify an `initialState` when there's a deep link (`Linking.getInitialURL()`).\n * @param props.onReady Callback which is called after the navigation tree mounts.\n * @param props.onStateChange Callback which is called with the latest navigation state when it changes.\n * @param props.theme Theme object for the navigators.\n * @param props.linking Options for deep linking. Deep link handling is enabled when this prop is provided, unless `linking.enabled` is `false`.\n * @param props.fallback Fallback component to render until we have finished getting initial state when linking is enabled. Defaults to `null`.\n * @param props.documentTitle Options to configure the document title on Web. Updating document title is handled by default unless `documentTitle.enabled` is `false`.\n * @param props.children Child elements to render the content.\n * @param props.ref Ref object which refers to the navigation object containing helper methods.\n */\nfunction NavigationContainerInner(\n {\n theme = DefaultTheme,\n linking,\n fallback = null,\n documentTitle,\n onReady,\n ...rest\n }: Props<ParamListBase>,\n ref?: React.Ref<NavigationContainerRef<ParamListBase> | null>\n) {\n const isLinkingEnabled = linking ? linking.enabled !== false : false;\n\n if (linking?.config) {\n validatePathConfig(linking.config);\n }\n\n const refContainer =\n React.useRef<NavigationContainerRef<ParamListBase>>(null);\n\n useBackButton(refContainer);\n useDocumentTitle(refContainer, documentTitle);\n\n const { getInitialState } = useLinking(refContainer, {\n independent: rest.independent,\n enabled: isLinkingEnabled,\n prefixes: [],\n ...linking,\n });\n\n // Add additional linking related info to the ref\n // This will be used by the devtools\n React.useEffect(() => {\n if (refContainer.current) {\n REACT_NAVIGATION_DEVTOOLS.set(refContainer.current, {\n get linking() {\n return {\n ...linking,\n enabled: isLinkingEnabled,\n prefixes: linking?.prefixes ?? [],\n getStateFromPath: linking?.getStateFromPath ?? getStateFromPath,\n getPathFromState: linking?.getPathFromState ?? getPathFromState,\n getActionFromState:\n linking?.getActionFromState ?? getActionFromState,\n };\n },\n });\n }\n });\n\n const [isResolved, initialState] = useThenable(getInitialState);\n\n React.useImperativeHandle(ref, () => refContainer.current);\n\n const linkingContext = React.useMemo(() => ({ options: linking }), [linking]);\n\n const isReady = rest.initialState != null || !isLinkingEnabled || isResolved;\n\n const onReadyRef = React.useRef(onReady);\n\n React.useEffect(() => {\n onReadyRef.current = onReady;\n });\n\n React.useEffect(() => {\n if (isReady) {\n onReadyRef.current?.();\n }\n }, [isReady]);\n\n if (!isReady) {\n // This is temporary until we have Suspense for data-fetching\n // Then the fallback will be handled by a parent `Suspense` component\n return fallback as React.ReactElement;\n }\n\n return (\n <LinkingContext.Provider value={linkingContext}>\n <ThemeProvider value={theme}>\n <BaseNavigationContainer\n {...rest}\n initialState={\n rest.initialState == null ? initialState : rest.initialState\n }\n ref={refContainer}\n />\n </ThemeProvider>\n </LinkingContext.Provider>\n );\n}\n\nconst NavigationContainer = React.forwardRef(NavigationContainerInner) as <\n RootParamList extends {} = ReactNavigation.RootParamList\n>(\n props: Props<RootParamList> & {\n ref?: React.Ref<NavigationContainerRef<RootParamList>>;\n }\n) => React.ReactElement;\n\nexport default NavigationContainer;\n"]}
@@ -24,10 +24,11 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
24
24
  * @param props.children Child elements to render the content.
25
25
  * @param props.ref Ref object which contains helper methods.
26
26
  */
27
- var _default = /*#__PURE__*/React.forwardRef(function ServerContainer({
28
- children,
29
- location
30
- }, ref) {
27
+ var _default = /*#__PURE__*/React.forwardRef(function ServerContainer(_ref, ref) {
28
+ let {
29
+ children,
30
+ location
31
+ } = _ref;
31
32
  React.useEffect(() => {
32
33
  console.error("'ServerContainer' should only be used on the server with 'react-dom/server' for SSR.");
33
34
  }, []);
@@ -1 +1 @@
1
- {"version":3,"sources":["ServerContainer.tsx"],"names":["React","forwardRef","ServerContainer","children","location","ref","useEffect","console","error","current","value","getCurrentOptions","options"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;;;;;;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;4BACeA,KAAK,CAACC,UAAN,CAAiB,SAASC,eAAT,CAC9B;AAAEC,EAAAA,QAAF;AAAYC,EAAAA;AAAZ,CAD8B,EAE9BC,GAF8B,EAG9B;AACAL,EAAAA,KAAK,CAACM,SAAN,CAAgB,MAAM;AACpBC,IAAAA,OAAO,CAACC,KAAR,CACE,sFADF;AAGD,GAJD,EAIG,EAJH;AAMA,QAAMC,OAA6B,GAAG,EAAtC;;AAEA,MAAIJ,GAAJ,EAAS;AACP,UAAMK,KAAK,GAAG;AACZC,MAAAA,iBAAiB,GAAG;AAClB,eAAOF,OAAO,CAACG,OAAf;AACD;;AAHW,KAAd,CADO,CAOP;AACA;AACA;AACA;;AACA,QAAI,OAAOP,GAAP,KAAe,UAAnB,EAA+B;AAC7BA,MAAAA,GAAG,CAACK,KAAD,CAAH;AACD,KAFD,MAEO;AACL;AACAL,MAAAA,GAAG,CAACI,OAAJ,GAAcC,KAAd;AACD;AACF;;AAED,sBACE,oBAAC,sBAAD,CAAe,QAAf;AAAwB,IAAA,KAAK,EAAE;AAAEN,MAAAA;AAAF;AAA/B,kBACE,oBAAC,0BAAD,CAAsB,QAAtB;AAA+B,IAAA,KAAK,EAAEK;AAAtC,KACGN,QADH,CADF,CADF;AAOD,CAtCc,C","sourcesContent":["import { CurrentRenderContext } from '@react-navigation/core';\nimport * as React from 'react';\n\nimport ServerContext, { ServerContextType } from './ServerContext';\nimport type { ServerContainerRef } from './types';\n\ntype Props = ServerContextType & {\n children: React.ReactNode;\n};\n\n/**\n * Container component for server rendering.\n *\n * @param props.location Location object to base the initial URL for SSR.\n * @param props.children Child elements to render the content.\n * @param props.ref Ref object which contains helper methods.\n */\nexport default React.forwardRef(function ServerContainer(\n { children, location }: Props,\n ref: React.Ref<ServerContainerRef>\n) {\n React.useEffect(() => {\n console.error(\n \"'ServerContainer' should only be used on the server with 'react-dom/server' for SSR.\"\n );\n }, []);\n\n const current: { options?: object } = {};\n\n if (ref) {\n const value = {\n getCurrentOptions() {\n return current.options;\n },\n };\n\n // We write to the `ref` during render instead of `React.useImperativeHandle`\n // This is because `useImperativeHandle` will update the ref after 'commit',\n // and there's no 'commit' phase during SSR.\n // Mutating ref during render is unsafe in concurrent mode, but we don't care about it for SSR.\n if (typeof ref === 'function') {\n ref(value);\n } else {\n // @ts-expect-error: the TS types are incorrect and say that ref.current is readonly\n ref.current = value;\n }\n }\n\n return (\n <ServerContext.Provider value={{ location }}>\n <CurrentRenderContext.Provider value={current}>\n {children}\n </CurrentRenderContext.Provider>\n </ServerContext.Provider>\n );\n});\n"]}
1
+ {"version":3,"sources":["ServerContainer.tsx"],"names":["React","forwardRef","ServerContainer","ref","children","location","useEffect","console","error","current","value","getCurrentOptions","options"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;;;;;;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;4BACeA,KAAK,CAACC,UAAN,CAAiB,SAASC,eAAT,OAE9BC,GAF8B,EAG9B;AAAA,MAFA;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAEA;AACAL,EAAAA,KAAK,CAACM,SAAN,CAAgB,MAAM;AACpBC,IAAAA,OAAO,CAACC,KAAR,CACE,sFADF;AAGD,GAJD,EAIG,EAJH;AAMA,QAAMC,OAA6B,GAAG,EAAtC;;AAEA,MAAIN,GAAJ,EAAS;AACP,UAAMO,KAAK,GAAG;AACZC,MAAAA,iBAAiB,GAAG;AAClB,eAAOF,OAAO,CAACG,OAAf;AACD;;AAHW,KAAd,CADO,CAOP;AACA;AACA;AACA;;AACA,QAAI,OAAOT,GAAP,KAAe,UAAnB,EAA+B;AAC7BA,MAAAA,GAAG,CAACO,KAAD,CAAH;AACD,KAFD,MAEO;AACL;AACAP,MAAAA,GAAG,CAACM,OAAJ,GAAcC,KAAd;AACD;AACF;;AAED,sBACE,oBAAC,sBAAD,CAAe,QAAf;AAAwB,IAAA,KAAK,EAAE;AAAEL,MAAAA;AAAF;AAA/B,kBACE,oBAAC,0BAAD,CAAsB,QAAtB;AAA+B,IAAA,KAAK,EAAEI;AAAtC,KACGL,QADH,CADF,CADF;AAOD,CAtCc,C","sourcesContent":["import { CurrentRenderContext } from '@react-navigation/core';\nimport * as React from 'react';\n\nimport ServerContext, { ServerContextType } from './ServerContext';\nimport type { ServerContainerRef } from './types';\n\ntype Props = ServerContextType & {\n children: React.ReactNode;\n};\n\n/**\n * Container component for server rendering.\n *\n * @param props.location Location object to base the initial URL for SSR.\n * @param props.children Child elements to render the content.\n * @param props.ref Ref object which contains helper methods.\n */\nexport default React.forwardRef(function ServerContainer(\n { children, location }: Props,\n ref: React.Ref<ServerContainerRef>\n) {\n React.useEffect(() => {\n console.error(\n \"'ServerContainer' should only be used on the server with 'react-dom/server' for SSR.\"\n );\n }, []);\n\n const current: { options?: object } = {};\n\n if (ref) {\n const value = {\n getCurrentOptions() {\n return current.options;\n },\n };\n\n // We write to the `ref` during render instead of `React.useImperativeHandle`\n // This is because `useImperativeHandle` will update the ref after 'commit',\n // and there's no 'commit' phase during SSR.\n // Mutating ref during render is unsafe in concurrent mode, but we don't care about it for SSR.\n if (typeof ref === 'function') {\n ref(value);\n } else {\n // @ts-expect-error: the TS types are incorrect and say that ref.current is readonly\n ref.current = value;\n }\n }\n\n return (\n <ServerContext.Provider value={{ location }}>\n <CurrentRenderContext.Provider value={current}>\n {children}\n </CurrentRenderContext.Provider>\n </ServerContext.Provider>\n );\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["ServerContext.tsx"],"names":["ServerContext","React","createContext","undefined"],"mappings":";;;;;;;AAAA;;;;;;AASA,MAAMA,aAAa,gBACjBC,KAAK,CAACC,aAAN,CAAmDC,SAAnD,CADF;eAGeH,a","sourcesContent":["import * as React from 'react';\n\nexport type ServerContextType = {\n location?: {\n pathname: string;\n search: string;\n };\n};\n\nconst ServerContext =\n React.createContext<ServerContextType | undefined>(undefined);\n\nexport default ServerContext;\n"]}
1
+ {"version":3,"sources":["ServerContext.tsx"],"names":["ServerContext","React","createContext","undefined"],"mappings":";;;;;;;AAAA;;;;;;AASA,MAAMA,aAAa,gBAAGC,KAAK,CAACC,aAAN,CACpBC,SADoB,CAAtB;eAIeH,a","sourcesContent":["import * as React from 'react';\n\nexport type ServerContextType = {\n location?: {\n pathname: string;\n search: string;\n };\n};\n\nconst ServerContext = React.createContext<ServerContextType | undefined>(\n undefined\n);\n\nexport default ServerContext;\n"]}
@@ -16,34 +16,34 @@ var _exportNames = {
16
16
  useLinkTo: true,
17
17
  useScrollToTop: true
18
18
  };
19
- Object.defineProperty(exports, "Link", {
19
+ Object.defineProperty(exports, "DarkTheme", {
20
20
  enumerable: true,
21
21
  get: function () {
22
- return _Link.default;
22
+ return _DarkTheme.default;
23
23
  }
24
24
  });
25
- Object.defineProperty(exports, "NavigationContainer", {
25
+ Object.defineProperty(exports, "DefaultTheme", {
26
26
  enumerable: true,
27
27
  get: function () {
28
- return _NavigationContainer.default;
28
+ return _DefaultTheme.default;
29
29
  }
30
30
  });
31
- Object.defineProperty(exports, "ServerContainer", {
31
+ Object.defineProperty(exports, "Link", {
32
32
  enumerable: true,
33
33
  get: function () {
34
- return _ServerContainer.default;
34
+ return _Link.default;
35
35
  }
36
36
  });
37
- Object.defineProperty(exports, "DarkTheme", {
37
+ Object.defineProperty(exports, "NavigationContainer", {
38
38
  enumerable: true,
39
39
  get: function () {
40
- return _DarkTheme.default;
40
+ return _NavigationContainer.default;
41
41
  }
42
42
  });
43
- Object.defineProperty(exports, "DefaultTheme", {
43
+ Object.defineProperty(exports, "ServerContainer", {
44
44
  enumerable: true,
45
45
  get: function () {
46
- return _DefaultTheme.default;
46
+ return _ServerContainer.default;
47
47
  }
48
48
  });
49
49
  Object.defineProperty(exports, "ThemeProvider", {
@@ -52,12 +52,6 @@ Object.defineProperty(exports, "ThemeProvider", {
52
52
  return _ThemeProvider.default;
53
53
  }
54
54
  });
55
- Object.defineProperty(exports, "useTheme", {
56
- enumerable: true,
57
- get: function () {
58
- return _useTheme.default;
59
- }
60
- });
61
55
  Object.defineProperty(exports, "useLinkBuilder", {
62
56
  enumerable: true,
63
57
  get: function () {
@@ -82,6 +76,12 @@ Object.defineProperty(exports, "useScrollToTop", {
82
76
  return _useScrollToTop.default;
83
77
  }
84
78
  });
79
+ Object.defineProperty(exports, "useTheme", {
80
+ enumerable: true,
81
+ get: function () {
82
+ return _useTheme.default;
83
+ }
84
+ });
85
85
 
86
86
  var _Link = _interopRequireDefault(require("./Link"));
87
87
 
@@ -15,10 +15,11 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
15
15
 
16
16
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
17
 
18
- function ThemeProvider({
19
- value,
20
- children
21
- }) {
18
+ function ThemeProvider(_ref) {
19
+ let {
20
+ value,
21
+ children
22
+ } = _ref;
22
23
  return /*#__PURE__*/React.createElement(_ThemeContext.default.Provider, {
23
24
  value: value
24
25
  }, children);
@@ -1 +1 @@
1
- {"version":3,"sources":["ThemeProvider.tsx"],"names":["ThemeProvider","value","children"],"mappings":";;;;;;;AAAA;;AAGA;;;;;;;;AAOe,SAASA,aAAT,CAAuB;AAAEC,EAAAA,KAAF;AAASC,EAAAA;AAAT,CAAvB,EAAmD;AAChE,sBACE,oBAAC,qBAAD,CAAc,QAAd;AAAuB,IAAA,KAAK,EAAED;AAA9B,KAAsCC,QAAtC,CADF;AAGD","sourcesContent":["import * as React from 'react';\n\nimport type { Theme } from '../types';\nimport ThemeContext from './ThemeContext';\n\ntype Props = {\n value: Theme;\n children: React.ReactNode;\n};\n\nexport default function ThemeProvider({ value, children }: Props) {\n return (\n <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>\n );\n}\n"]}
1
+ {"version":3,"sources":["ThemeProvider.tsx"],"names":["ThemeProvider","value","children"],"mappings":";;;;;;;AAAA;;AAGA;;;;;;;;AAOe,SAASA,aAAT,OAAmD;AAAA,MAA5B;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,GAA4B;AAChE,sBACE,oBAAC,qBAAD,CAAc,QAAd;AAAuB,IAAA,KAAK,EAAED;AAA9B,KAAsCC,QAAtC,CADF;AAGD","sourcesContent":["import * as React from 'react';\n\nimport type { Theme } from '../types';\nimport ThemeContext from './ThemeContext';\n\ntype Props = {\n value: Theme;\n children: React.ReactNode;\n};\n\nexport default function ThemeProvider({ value, children }: Props) {\n return (\n <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>\n );\n}\n"]}
@@ -14,14 +14,15 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
14
14
  /**
15
15
  * Set the document title for the active screen
16
16
  */
17
- function useDocumentTitle(ref, {
18
- enabled = true,
19
- formatter = (options, route) => {
20
- var _options$title;
21
-
22
- return (_options$title = options === null || options === void 0 ? void 0 : options.title) !== null && _options$title !== void 0 ? _options$title : route === null || route === void 0 ? void 0 : route.name;
23
- }
24
- } = {}) {
17
+ function useDocumentTitle(ref) {
18
+ let {
19
+ enabled = true,
20
+ formatter = (options, route) => {
21
+ var _options$title;
22
+
23
+ return (_options$title = options === null || options === void 0 ? void 0 : options.title) !== null && _options$title !== void 0 ? _options$title : route === null || route === void 0 ? void 0 : route.name;
24
+ }
25
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
25
26
  React.useEffect(() => {
26
27
  if (!enabled) {
27
28
  return;
@@ -1 +1 @@
1
- {"version":3,"sources":["useDocumentTitle.tsx"],"names":["useDocumentTitle","ref","enabled","formatter","options","route","title","name","React","useEffect","navigation","current","getCurrentOptions","getCurrentRoute","document","addListener","e","data"],"mappings":";;;;;;;AAIA;;;;;;AAIA;AACA;AACA;AACe,SAASA,gBAAT,CACbC,GADa,EAEb;AACEC,EAAAA,OAAO,GAAG,IADZ;AAEEC,EAAAA,SAAS,GAAG,CAACC,OAAD,EAAUC,KAAV;AAAA;;AAAA,6BAAoBD,OAApB,aAAoBA,OAApB,uBAAoBA,OAAO,CAAEE,KAA7B,2DAAsCD,KAAtC,aAAsCA,KAAtC,uBAAsCA,KAAK,CAAEE,IAA7C;AAAA;AAFd,IAG0B,EALb,EAMb;AACAC,EAAAA,KAAK,CAACC,SAAN,CAAgB,MAAM;AACpB,QAAI,CAACP,OAAL,EAAc;AACZ;AACD;;AAED,UAAMQ,UAAU,GAAGT,GAAG,CAACU,OAAvB;;AAEA,QAAID,UAAJ,EAAgB;AACd,YAAMJ,KAAK,GAAGH,SAAS,CACrBO,UAAU,CAACE,iBAAX,EADqB,EAErBF,UAAU,CAACG,eAAX,EAFqB,CAAvB;AAKAC,MAAAA,QAAQ,CAACR,KAAT,GAAiBA,KAAjB;AACD;;AAED,WAAOI,UAAP,aAAOA,UAAP,uBAAOA,UAAU,CAAEK,WAAZ,CAAwB,SAAxB,EAAoCC,CAAD,IAAO;AAC/C,YAAMV,KAAK,GAAGH,SAAS,CAACa,CAAC,CAACC,IAAF,CAAOb,OAAR,EAAiBM,UAAjB,aAAiBA,UAAjB,uBAAiBA,UAAU,CAAEG,eAAZ,EAAjB,CAAvB;AAEAC,MAAAA,QAAQ,CAACR,KAAT,GAAiBA,KAAjB;AACD,KAJM,CAAP;AAKD,GArBD;AAsBD","sourcesContent":["import type {\n NavigationContainerRef,\n ParamListBase,\n} from '@react-navigation/core';\nimport * as React from 'react';\n\nimport type { DocumentTitleOptions } from './types';\n\n/**\n * Set the document title for the active screen\n */\nexport default function useDocumentTitle(\n ref: React.RefObject<NavigationContainerRef<ParamListBase>>,\n {\n enabled = true,\n formatter = (options, route) => options?.title ?? route?.name,\n }: DocumentTitleOptions = {}\n) {\n React.useEffect(() => {\n if (!enabled) {\n return;\n }\n\n const navigation = ref.current;\n\n if (navigation) {\n const title = formatter(\n navigation.getCurrentOptions(),\n navigation.getCurrentRoute()\n );\n\n document.title = title;\n }\n\n return navigation?.addListener('options', (e) => {\n const title = formatter(e.data.options, navigation?.getCurrentRoute());\n\n document.title = title;\n });\n });\n}\n"]}
1
+ {"version":3,"sources":["useDocumentTitle.tsx"],"names":["useDocumentTitle","ref","enabled","formatter","options","route","title","name","React","useEffect","navigation","current","getCurrentOptions","getCurrentRoute","document","addListener","e","data"],"mappings":";;;;;;;AAIA;;;;;;AAIA;AACA;AACA;AACe,SAASA,gBAAT,CACbC,GADa,EAMb;AAAA,MAJA;AACEC,IAAAA,OAAO,GAAG,IADZ;AAEEC,IAAAA,SAAS,GAAG,CAACC,OAAD,EAAUC,KAAV;AAAA;;AAAA,+BAAoBD,OAApB,aAAoBA,OAApB,uBAAoBA,OAAO,CAAEE,KAA7B,2DAAsCD,KAAtC,aAAsCA,KAAtC,uBAAsCA,KAAK,CAAEE,IAA7C;AAAA;AAFd,GAIA,uEAD0B,EAC1B;AACAC,EAAAA,KAAK,CAACC,SAAN,CAAgB,MAAM;AACpB,QAAI,CAACP,OAAL,EAAc;AACZ;AACD;;AAED,UAAMQ,UAAU,GAAGT,GAAG,CAACU,OAAvB;;AAEA,QAAID,UAAJ,EAAgB;AACd,YAAMJ,KAAK,GAAGH,SAAS,CACrBO,UAAU,CAACE,iBAAX,EADqB,EAErBF,UAAU,CAACG,eAAX,EAFqB,CAAvB;AAKAC,MAAAA,QAAQ,CAACR,KAAT,GAAiBA,KAAjB;AACD;;AAED,WAAOI,UAAP,aAAOA,UAAP,uBAAOA,UAAU,CAAEK,WAAZ,CAAwB,SAAxB,EAAoCC,CAAD,IAAO;AAC/C,YAAMV,KAAK,GAAGH,SAAS,CAACa,CAAC,CAACC,IAAF,CAAOb,OAAR,EAAiBM,UAAjB,aAAiBA,UAAjB,uBAAiBA,UAAU,CAAEG,eAAZ,EAAjB,CAAvB;AAEAC,MAAAA,QAAQ,CAACR,KAAT,GAAiBA,KAAjB;AACD,KAJM,CAAP;AAKD,GArBD;AAsBD","sourcesContent":["import type {\n NavigationContainerRef,\n ParamListBase,\n} from '@react-navigation/core';\nimport * as React from 'react';\n\nimport type { DocumentTitleOptions } from './types';\n\n/**\n * Set the document title for the active screen\n */\nexport default function useDocumentTitle(\n ref: React.RefObject<NavigationContainerRef<ParamListBase>>,\n {\n enabled = true,\n formatter = (options, route) => options?.title ?? route?.name,\n }: DocumentTitleOptions = {}\n) {\n React.useEffect(() => {\n if (!enabled) {\n return;\n }\n\n const navigation = ref.current;\n\n if (navigation) {\n const title = formatter(\n navigation.getCurrentOptions(),\n navigation.getCurrentRoute()\n );\n\n document.title = title;\n }\n\n return navigation?.addListener('options', (e) => {\n const title = formatter(e.data.options, navigation?.getCurrentRoute());\n\n document.title = title;\n });\n });\n}\n"]}
@@ -47,12 +47,13 @@ const getStateFromParams = params => {
47
47
  */
48
48
 
49
49
 
50
- function useLinkProps({
51
- to,
52
- action
53
- }) {
50
+ function useLinkProps(_ref) {
54
51
  var _options$getPathFromS;
55
52
 
53
+ let {
54
+ to,
55
+ action
56
+ } = _ref;
56
57
  const root = React.useContext(_core.NavigationContainerRefContext);
57
58
  const navigation = React.useContext(_core.NavigationHelpersContext);
58
59
  const {
@@ -69,7 +70,9 @@ function useLinkProps({
69
70
  shouldHandle = e ? !e.defaultPrevented : true;
70
71
  } else if (!e.defaultPrevented && // onPress prevented default
71
72
  // @ts-expect-error: these properties exist on web, but not in React Native
72
- !(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) && (e.button == null || e.button === 0) && // ignore everything but left clicks
73
+ !(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) && ( // ignore clicks with modifier keys
74
+ // @ts-expect-error: these properties exist on web, but not in React Native
75
+ e.button == null || e.button === 0) && // ignore everything but left clicks
73
76
  // @ts-expect-error: these properties exist on web, but not in React Native
74
77
  [undefined, null, '', 'self'].includes((_e$currentTarget = e.currentTarget) === null || _e$currentTarget === void 0 ? void 0 : _e$currentTarget.target) // let browser handle "target=_blank" etc.
75
78
  ) {
@@ -1 +1 @@
1
- {"version":3,"sources":["useLinkProps.tsx"],"names":["getStateFromParams","params","state","screen","routes","name","undefined","useLinkProps","to","action","root","React","useContext","NavigationContainerRefContext","navigation","NavigationHelpersContext","options","LinkingContext","linkTo","onPress","e","shouldHandle","Platform","OS","defaultPrevented","metaKey","altKey","ctrlKey","shiftKey","button","includes","currentTarget","target","preventDefault","dispatch","Error","getPathFromStateHelper","getPathFromState","href","config","accessibilityRole"],"mappings":";;;;;;;AAAA;;AASA;;AACA;;AAEA;;AACA;;;;;;;;AAOA,MAAMA,kBAAkB,GACtBC,MADyB,IAEuC;AAChE,MAAIA,MAAJ,aAAIA,MAAJ,eAAIA,MAAM,CAAEC,KAAZ,EAAmB;AACjB,WAAOD,MAAM,CAACC,KAAd;AACD;;AAED,MAAID,MAAJ,aAAIA,MAAJ,eAAIA,MAAM,CAAEE,MAAZ,EAAoB;AAClB,WAAO;AACLC,MAAAA,MAAM,EAAE,CACN;AACEC,QAAAA,IAAI,EAAEJ,MAAM,CAACE,MADf;AAEEF,QAAAA,MAAM,EAAEA,MAAM,CAACA,MAFjB;AAGE;AACAC,QAAAA,KAAK,EAAED,MAAM,CAACE,MAAP,GACHH,kBAAkB,CAChBC,MAAM,CAACA,MADS,CADf,GAMHK;AAVN,OADM;AADH,KAAP;AAgBD;;AAED,SAAOA,SAAP;AACD,CA3BD;AA6BA;AACA;AACA;AACA;AACA;AACA;;;AACe,SAASC,YAAT,CAEb;AAAEC,EAAAA,EAAF;AAAMC,EAAAA;AAAN,CAFa,EAEqB;AAAA;;AAClC,QAAMC,IAAI,GAAGC,KAAK,CAACC,UAAN,CAAiBC,mCAAjB,CAAb;AACA,QAAMC,UAAU,GAAGH,KAAK,CAACC,UAAN,CAAiBG,8BAAjB,CAAnB;AACA,QAAM;AAAEC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BAAGA,OAAO,CAAEqB,gBAAZ,yEAAgCA,sBAA5D;AAEA,QAAMC,IAAI,GACR,OAAO9B,EAAP,KAAc,QAAd,GACIA,EADJ,GAEI4B,sBAAsB,CACpB;AACEhC,IAAAA,MAAM,EAAE,CACN;AACEC,MAAAA,IAAI,EAAEG,EAAE,CAACL,MADX;AAEE;AACAF,MAAAA,MAAM,EAAEO,EAAE,CAACP,MAHb;AAIE;AACAC,MAAAA,KAAK,EAAEF,kBAAkB,CAACQ,EAAE,CAACP,MAAJ;AAL3B,KADM;AADV,GADoB,EAYpBe,OAZoB,aAYpBA,OAZoB,uBAYpBA,OAAO,CAAEuB,MAZW,CAH5B;AAkBA,SAAO;AACLD,IAAAA,IADK;AAELE,IAAAA,iBAAiB,EAAE,MAFd;AAGLrB,IAAAA;AAHK,GAAP;AAKD","sourcesContent":["import {\n getPathFromState,\n NavigationAction,\n NavigationContainerRefContext,\n NavigationHelpersContext,\n NavigatorScreenParams,\n ParamListBase,\n} from '@react-navigation/core';\nimport type { NavigationState, PartialState } from '@react-navigation/routers';\nimport * as React from 'react';\nimport { GestureResponderEvent, Platform } from 'react-native';\n\nimport LinkingContext from './LinkingContext';\nimport useLinkTo, { To } from './useLinkTo';\n\ntype Props<ParamList extends ReactNavigation.RootParamList> = {\n to: To<ParamList>;\n action?: NavigationAction;\n};\n\nconst getStateFromParams = (\n params: NavigatorScreenParams<ParamListBase, NavigationState> | undefined\n): PartialState<NavigationState> | NavigationState | undefined => {\n if (params?.state) {\n return params.state;\n }\n\n if (params?.screen) {\n return {\n routes: [\n {\n name: params.screen,\n params: params.params,\n // @ts-expect-error\n state: params.screen\n ? getStateFromParams(\n params.params as\n | NavigatorScreenParams<ParamListBase, NavigationState>\n | undefined\n )\n : undefined,\n },\n ],\n };\n }\n\n return undefined;\n};\n\n/**\n * Hook to get props for an anchor tag so it can work with in page navigation.\n *\n * @param props.to Absolute path to screen (e.g. `/feeds/hot`).\n * @param props.action Optional action to use for in-page navigation. By default, the path is parsed to an action based on linking config.\n */\nexport default function useLinkProps<\n ParamList extends ReactNavigation.RootParamList\n>({ to, action }: Props<ParamList>) {\n const root = React.useContext(NavigationContainerRefContext);\n const navigation = React.useContext(NavigationHelpersContext);\n const { options } = React.useContext(LinkingContext);\n const linkTo = useLinkTo<ParamList>();\n\n const onPress = (\n e?: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent\n ) => {\n let shouldHandle = false;\n\n if (Platform.OS !== 'web' || !e) {\n shouldHandle = e ? !e.defaultPrevented : true;\n } else if (\n !e.defaultPrevented && // onPress prevented default\n // @ts-expect-error: these properties exist on web, but not in React Native\n !(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) && // ignore clicks with modifier keys\n // @ts-expect-error: these properties exist on web, but not in React Native\n (e.button == null || e.button === 0) && // ignore everything but left clicks\n // @ts-expect-error: these properties exist on web, but not in React Native\n [undefined, null, '', 'self'].includes(e.currentTarget?.target) // let browser handle \"target=_blank\" etc.\n ) {\n e.preventDefault();\n shouldHandle = true;\n }\n\n if (shouldHandle) {\n if (action) {\n if (navigation) {\n navigation.dispatch(action);\n } else if (root) {\n root.dispatch(action);\n } else {\n throw new Error(\n \"Couldn't find a navigation object. Is your component inside NavigationContainer?\"\n );\n }\n } else {\n linkTo(to);\n }\n }\n };\n\n const getPathFromStateHelper = options?.getPathFromState ?? getPathFromState;\n\n const href =\n typeof to === 'string'\n ? to\n : getPathFromStateHelper(\n {\n routes: [\n {\n name: to.screen,\n // @ts-expect-error\n params: to.params,\n // @ts-expect-error\n state: getStateFromParams(to.params),\n },\n ],\n },\n options?.config\n );\n\n return {\n href,\n accessibilityRole: 'link' as const,\n onPress,\n };\n}\n"]}
1
+ {"version":3,"sources":["useLinkProps.tsx"],"names":["getStateFromParams","params","state","screen","routes","name","undefined","useLinkProps","to","action","root","React","useContext","NavigationContainerRefContext","navigation","NavigationHelpersContext","options","LinkingContext","linkTo","onPress","e","shouldHandle","Platform","OS","defaultPrevented","metaKey","altKey","ctrlKey","shiftKey","button","includes","currentTarget","target","preventDefault","dispatch","Error","getPathFromStateHelper","getPathFromState","href","config","accessibilityRole"],"mappings":";;;;;;;AAAA;;AASA;;AACA;;AAEA;;AACA;;;;;;;;AAOA,MAAMA,kBAAkB,GACtBC,MADyB,IAEuC;AAChE,MAAIA,MAAJ,aAAIA,MAAJ,eAAIA,MAAM,CAAEC,KAAZ,EAAmB;AACjB,WAAOD,MAAM,CAACC,KAAd;AACD;;AAED,MAAID,MAAJ,aAAIA,MAAJ,eAAIA,MAAM,CAAEE,MAAZ,EAAoB;AAClB,WAAO;AACLC,MAAAA,MAAM,EAAE,CACN;AACEC,QAAAA,IAAI,EAAEJ,MAAM,CAACE,MADf;AAEEF,QAAAA,MAAM,EAAEA,MAAM,CAACA,MAFjB;AAGE;AACAC,QAAAA,KAAK,EAAED,MAAM,CAACE,MAAP,GACHH,kBAAkB,CAChBC,MAAM,CAACA,MADS,CADf,GAMHK;AAVN,OADM;AADH,KAAP;AAgBD;;AAED,SAAOA,SAAP;AACD,CA3BD;AA6BA;AACA;AACA;AACA;AACA;AACA;;;AACe,SAASC,YAAT,OAEqB;AAAA;;AAAA,MAAlC;AAAEC,IAAAA,EAAF;AAAMC,IAAAA;AAAN,GAAkC;AAClC,QAAMC,IAAI,GAAGC,KAAK,CAACC,UAAN,CAAiBC,mCAAjB,CAAb;AACA,QAAMC,UAAU,GAAGH,KAAK,CAACC,UAAN,CAAiBG,8BAAjB,CAAnB;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAcL,KAAK,CAACC,UAAN,CAAiBK,uBAAjB,CAApB;AACA,QAAMC,MAAM,GAAG,yBAAf;;AAEA,QAAMC,OAAO,GACXC,CADc,IAEX;AAAA;;AACH,QAAIC,YAAY,GAAG,KAAnB;;AAEA,QAAIC,sBAASC,EAAT,KAAgB,KAAhB,IAAyB,CAACH,CAA9B,EAAiC;AAC/BC,MAAAA,YAAY,GAAGD,CAAC,GAAG,CAACA,CAAC,CAACI,gBA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K,EAAEF,kBAAkB,CAACQ,EAAE,CAACP,MAAJ;AAL3B,KADM;AADV,GADoB,EAYpBe,OAZoB,aAYpBA,OAZoB,uBAYpBA,OAAO,CAAEuB,MAZW,CAH5B;AAkBA,SAAO;AACLD,IAAAA,IADK;AAELE,IAAAA,iBAAiB,EAAE,MAFd;AAGLrB,IAAAA;AAHK,GAAP;AAKD","sourcesContent":["import {\n getPathFromState,\n NavigationAction,\n NavigationContainerRefContext,\n NavigationHelpersContext,\n NavigatorScreenParams,\n ParamListBase,\n} from '@react-navigation/core';\nimport type { NavigationState, PartialState } from '@react-navigation/routers';\nimport * as React from 'react';\nimport { GestureResponderEvent, Platform } from 'react-native';\n\nimport LinkingContext from './LinkingContext';\nimport useLinkTo, { To } from './useLinkTo';\n\ntype Props<ParamList extends ReactNavigation.RootParamList> = {\n to: To<ParamList>;\n action?: NavigationAction;\n};\n\nconst getStateFromParams = (\n params: NavigatorScreenParams<ParamListBase, NavigationState> | undefined\n): PartialState<NavigationState> | NavigationState | undefined => {\n if (params?.state) {\n return params.state;\n }\n\n if (params?.screen) {\n return {\n routes: [\n {\n name: params.screen,\n params: params.params,\n // @ts-expect-error\n state: params.screen\n ? getStateFromParams(\n params.params as\n | NavigatorScreenParams<ParamListBase, NavigationState>\n | undefined\n )\n : undefined,\n },\n ],\n };\n }\n\n return undefined;\n};\n\n/**\n * Hook to get props for an anchor tag so it can work with in page navigation.\n *\n * @param props.to Absolute path to screen (e.g. `/feeds/hot`).\n * @param props.action Optional action to use for in-page navigation. By default, the path is parsed to an action based on linking config.\n */\nexport default function useLinkProps<\n ParamList extends ReactNavigation.RootParamList\n>({ to, action }: Props<ParamList>) {\n const root = React.useContext(NavigationContainerRefContext);\n const navigation = React.useContext(NavigationHelpersContext);\n const { options } = React.useContext(LinkingContext);\n const linkTo = useLinkTo<ParamList>();\n\n const onPress = (\n e?: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent\n ) => {\n let shouldHandle = false;\n\n if (Platform.OS !== 'web' || !e) {\n shouldHandle = e ? !e.defaultPrevented : true;\n } else if (\n !e.defaultPrevented && // onPress prevented default\n // @ts-expect-error: these properties exist on web, but not in React Native\n !(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) && // ignore clicks with modifier keys\n // @ts-expect-error: these properties exist on web, but not in React Native\n (e.button == null || e.button === 0) && // ignore everything but left clicks\n // @ts-expect-error: these properties exist on web, but not in React Native\n [undefined, null, '', 'self'].includes(e.currentTarget?.target) // let browser handle \"target=_blank\" etc.\n ) {\n e.preventDefault();\n shouldHandle = true;\n }\n\n if (shouldHandle) {\n if (action) {\n if (navigation) {\n navigation.dispatch(action);\n } else if (root) {\n root.dispatch(action);\n } else {\n throw new Error(\n \"Couldn't find a navigation object. Is your component inside NavigationContainer?\"\n );\n }\n } else {\n linkTo(to);\n }\n }\n };\n\n const getPathFromStateHelper = options?.getPathFromState ?? getPathFromState;\n\n const href =\n typeof to === 'string'\n ? to\n : getPathFromStateHelper(\n {\n routes: [\n {\n name: to.screen,\n // @ts-expect-error\n params: to.params,\n // @ts-expect-error\n state: getStateFromParams(to.params),\n },\n ],\n },\n options?.config\n );\n\n return {\n href,\n accessibilityRole: 'link' as const,\n onPress,\n };\n}\n"]}
@@ -7,18 +7,20 @@ exports.default = useLinking;
7
7
 
8
8
  var _core = require("@react-navigation/core");
9
9
 
10
+ var _fastDeepEqual = _interopRequireDefault(require("fast-deep-equal"));
11
+
10
12
  var _nonSecure = require("nanoid/non-secure");
11
13
 
12
14
  var React = _interopRequireWildcard(require("react"));
13
15
 
14
16
  var _ServerContext = _interopRequireDefault(require("./ServerContext"));
15
17
 
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
18
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
19
 
20
20
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
21
 
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
+
22
24
  const createMemoryHistory = () => {
23
25
  let index = 0;
24
26
  let items = []; // Pending callbacks for `history.go(n)`
@@ -57,9 +59,11 @@ const createMemoryHistory = () => {
57
59
  return items[index];
58
60
  },
59
61
 
60
- backIndex({
61
- path
62
- }) {
62
+ backIndex(_ref) {
63
+ let {
64
+ path
65
+ } = _ref;
66
+
63
67
  // We need to find the index from the element before current to get closest path to go back to
64
68
  for (let i = index - 1; i >= 0; i--) {
65
69
  const item = items[i];
@@ -72,10 +76,11 @@ const createMemoryHistory = () => {
72
76
  return -1;
73
77
  },
74
78
 
75
- push({
76
- path,
77
- state
78
- }) {
79
+ push(_ref2) {
80
+ let {
81
+ path,
82
+ state
83
+ } = _ref2;
79
84
  interrupt();
80
85
  const id = (0, _nonSecure.nanoid)(); // When a new entry is pushed, all the existing entries after index will be inaccessible
81
86
  // So we remove any existing entries after the current index to clean them up
@@ -96,12 +101,13 @@ const createMemoryHistory = () => {
96
101
  }, '', path);
97
102
  },
98
103
 
99
- replace({
100
- path,
101
- state
102
- }) {
104
+ replace(_ref3) {
103
105
  var _window$history$state2, _window$history$state3;
104
106
 
107
+ let {
108
+ path,
109
+ state
110
+ } = _ref3;
105
111
  interrupt();
106
112
  const id = (_window$history$state2 = (_window$history$state3 = window.history.state) === null || _window$history$state3 === void 0 ? void 0 : _window$history$state3.id) !== null && _window$history$state2 !== void 0 ? _window$history$state2 : (0, _nonSecure.nanoid)();
107
113
 
@@ -138,20 +144,13 @@ const createMemoryHistory = () => {
138
144
  go(n) {
139
145
  interrupt();
140
146
 
141
- if (n > 0) {
142
- // We shouldn't go forward more than available index
143
- n = Math.min(n, items.length - 1);
144
- } else if (n < 0) {
145
- // We shouldn't go back more than the 0 index
146
- // Otherwise we'll exit the page
147
- n = index + n < 0 ? -index : n;
148
- }
149
-
150
147
  if (n === 0) {
151
148
  return;
152
- }
149
+ } // We shouldn't go back more than the 0 index (otherwise we'll exit the page)
150
+ // Or forward more than the available index (or the app will crash)
151
+
153
152
 
154
- index += n; // When we call `history.go`, `popstate` will fire when there's history to go back to
153
+ index = n < 0 ? Math.max(index - n, 0) : Math.min(index + n, items.length - 1); // When we call `history.go`, `popstate` will fire when there's history to go back to
155
154
  // So we need to somehow handle following cases:
156
155
  // - There's history to go back, `history.go` is called, and `popstate` fires
157
156
  // - `history.go` is called multiple times, we need to resolve on respective `popstate`
@@ -304,14 +303,15 @@ const series = cb => {
304
303
 
305
304
  let linkingHandlers = [];
306
305
 
307
- function useLinking(ref, {
308
- independent,
309
- enabled = true,
310
- config,
311
- getStateFromPath = _core.getStateFromPath,
312
- getPathFromState = _core.getPathFromState,
313
- getActionFromState = _core.getActionFromState
314
- }) {
306
+ function useLinking(ref, _ref4) {
307
+ let {
308
+ independent,
309
+ enabled = true,
310
+ config,
311
+ getStateFromPath = _core.getStateFromPath,
312
+ getPathFromState = _core.getPathFromState,
313
+ getActionFromState = _core.getActionFromState
314
+ } = _ref4;
315
315
  React.useEffect(() => {
316
316
  if (process.env.NODE_ENV === 'production') {
317
317
  return undefined;
@@ -433,7 +433,8 @@ function useLinking(ref, {
433
433
  } catch (e) {
434
434
  // Ignore any errors from deep linking.
435
435
  // This could happen in case of malformed links, navigation object not being initialized etc.
436
- console.warn(`An error occurred when trying to handle the link '${path}': ${e.message}`);
436
+ console.warn(`An error occurred when trying to handle the link '${path}': ${typeof e === 'object' && e != null && 'message' in e ? // @ts-expect-error: we're already checking for this
437
+ e.message : e}`);
437
438
  }
438
439
  } else {
439
440
  navigation.resetRoot(state);
@@ -454,16 +455,32 @@ function useLinking(ref, {
454
455
  return;
455
456
  }
456
457
 
458
+ const getPathForRoute = (route, state) => {
459
+ // If the `route` object contains a `path`, use that path as long as `route.name` and `params` still match
460
+ // This makes sure that we preserve the original URL for wildcard routes
461
+ if (route !== null && route !== void 0 && route.path) {
462
+ const stateForPath = getStateFromPathRef.current(route.path, configRef.current);
463
+
464
+ if (stateForPath) {
465
+ const focusedRoute = (0, _core.findFocusedRoute)(stateForPath);
466
+
467
+ if (focusedRoute && focusedRoute.name === route.name && (0, _fastDeepEqual.default)(focusedRoute.params, route.params)) {
468
+ return route.path;
469
+ }
470
+ }
471
+ }
472
+
473
+ return getPathFromStateRef.current(state, configRef.current);
474
+ };
475
+
457
476
  if (ref.current) {
458
477
  // We need to record the current metadata on the first render if they aren't set
459
478
  // This will allow the initial state to be in the history entry
460
479
  const state = ref.current.getRootState();
461
480
 
462
481
  if (state) {
463
- var _route$path;
464
-
465
482
  const route = (0, _core.findFocusedRoute)(state);
466
- const path = (_route$path = route === null || route === void 0 ? void 0 : route.path) !== null && _route$path !== void 0 ? _route$path : getPathFromStateRef.current(state, configRef.current);
483
+ const path = getPathForRoute(route, state);
467
484
 
468
485
  if (previousStateRef.current === undefined) {
469
486
  previousStateRef.current = state;
@@ -477,8 +494,6 @@ function useLinking(ref, {
477
494
  }
478
495
 
479
496
  const onStateChange = async () => {
480
- var _route$path2;
481
-
482
497
  const navigation = ref.current;
483
498
 
484
499
  if (!navigation || !enabled) {
@@ -486,10 +501,15 @@ function useLinking(ref, {
486
501
  }
487
502
 
488
503
  const previousState = previousStateRef.current;
489
- const state = navigation.getRootState();
504
+ const state = navigation.getRootState(); // root state may not available, for example when root navigators switch inside the container
505
+
506
+ if (!state) {
507
+ return;
508
+ }
509
+
490
510
  const pendingPath = pendingPopStatePathRef.current;
491
511
  const route = (0, _core.findFocusedRoute)(state);
492
- const path = (_route$path2 = route === null || route === void 0 ? void 0 : route.path) !== null && _route$path2 !== void 0 ? _route$path2 : getPathFromStateRef.current(state, configRef.current);
512
+ const path = getPathForRoute(route, state);
493
513
  previousStateRef.current = state;
494
514
  pendingPopStatePathRef.current = undefined; // To detect the kind of state change, we need to:
495
515
  // - Find the common focused navigation state in previous and current state