@react-navigation/core 7.0.0-alpha.0 → 7.0.0-alpha.10
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.
- package/lib/commonjs/BaseNavigationContainer.js +57 -63
- package/lib/commonjs/BaseNavigationContainer.js.map +1 -1
- package/lib/commonjs/CurrentRenderContext.js +4 -6
- package/lib/commonjs/CurrentRenderContext.js.map +1 -1
- package/lib/commonjs/DeprecatedNavigationInChildContext.js +4 -6
- package/lib/commonjs/DeprecatedNavigationInChildContext.js.map +1 -1
- package/lib/commonjs/EnsureSingleNavigator.js +4 -5
- package/lib/commonjs/EnsureSingleNavigator.js.map +1 -1
- package/lib/commonjs/Group.js +1 -1
- package/lib/commonjs/Group.js.map +1 -1
- package/lib/commonjs/NavigationBuilderContext.js +4 -6
- package/lib/commonjs/NavigationBuilderContext.js.map +1 -1
- package/lib/commonjs/NavigationContainerRefContext.js +4 -6
- package/lib/commonjs/NavigationContainerRefContext.js.map +1 -1
- package/lib/commonjs/NavigationContext.js +4 -6
- package/lib/commonjs/NavigationContext.js.map +1 -1
- package/lib/commonjs/NavigationHelpersContext.js +4 -6
- package/lib/commonjs/NavigationHelpersContext.js.map +1 -1
- package/lib/commonjs/NavigationIndependentTree.js +9 -10
- package/lib/commonjs/NavigationIndependentTree.js.map +1 -1
- package/lib/commonjs/NavigationIndependentTreeContext.js +4 -6
- package/lib/commonjs/NavigationIndependentTreeContext.js.map +1 -1
- package/lib/commonjs/NavigationRouteContext.js +4 -6
- package/lib/commonjs/NavigationRouteContext.js.map +1 -1
- package/lib/commonjs/NavigationStateContext.js +4 -5
- package/lib/commonjs/NavigationStateContext.js.map +1 -1
- package/lib/commonjs/PreventRemoveContext.js +9 -6
- package/lib/commonjs/PreventRemoveContext.js.map +1 -1
- package/lib/commonjs/PreventRemoveProvider.js +16 -18
- package/lib/commonjs/PreventRemoveProvider.js.map +1 -1
- package/lib/commonjs/SceneView.js +10 -11
- package/lib/commonjs/SceneView.js.map +1 -1
- package/lib/commonjs/Screen.js +1 -1
- package/lib/commonjs/Screen.js.map +1 -1
- package/lib/commonjs/StaticContainer.js +5 -7
- package/lib/commonjs/StaticContainer.js.map +1 -1
- package/lib/commonjs/StaticNavigation.js +36 -10
- package/lib/commonjs/StaticNavigation.js.map +1 -1
- package/lib/commonjs/UnhandledActionContext.js +4 -6
- package/lib/commonjs/UnhandledActionContext.js.map +1 -1
- package/lib/commonjs/checkDuplicateRouteNames.js +2 -3
- package/lib/commonjs/checkDuplicateRouteNames.js.map +1 -1
- package/lib/commonjs/checkSerializable.js +1 -1
- package/lib/commonjs/checkSerializable.js.map +1 -1
- package/lib/commonjs/createNavigationContainerRef.js +2 -3
- package/lib/commonjs/createNavigationContainerRef.js.map +1 -1
- package/lib/commonjs/createNavigatorFactory.js +7 -11
- package/lib/commonjs/createNavigatorFactory.js.map +1 -1
- package/lib/commonjs/findFocusedRoute.js +3 -5
- package/lib/commonjs/findFocusedRoute.js.map +1 -1
- package/lib/commonjs/getActionFromState.js +7 -9
- package/lib/commonjs/getActionFromState.js.map +1 -1
- package/lib/commonjs/getFocusedRouteNameFromRoute.js +2 -2
- package/lib/commonjs/getFocusedRouteNameFromRoute.js.map +1 -1
- package/lib/commonjs/getPathFromState.js +24 -25
- package/lib/commonjs/getPathFromState.js.map +1 -1
- package/lib/commonjs/getStateFromPath.js +29 -22
- package/lib/commonjs/getStateFromPath.js.map +1 -1
- package/lib/commonjs/index.js +78 -76
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/isArrayEqual.js +1 -1
- package/lib/commonjs/isArrayEqual.js.map +1 -1
- package/lib/commonjs/isRecordEqual.js +1 -1
- package/lib/commonjs/isRecordEqual.js.map +1 -1
- package/lib/commonjs/theming/ThemeContext.js +12 -0
- package/lib/commonjs/theming/ThemeContext.js.map +1 -0
- package/lib/commonjs/theming/ThemeProvider.js +20 -0
- package/lib/commonjs/theming/ThemeProvider.js.map +1 -0
- package/lib/commonjs/theming/useTheme.js +18 -0
- package/lib/commonjs/theming/useTheme.js.map +1 -0
- package/lib/commonjs/types.js +1 -8
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/useChildListeners.js +3 -3
- package/lib/commonjs/useChildListeners.js.map +1 -1
- package/lib/commonjs/useComponent.js +3 -3
- package/lib/commonjs/useComponent.js.map +1 -1
- package/lib/commonjs/useCurrentRender.js +5 -6
- package/lib/commonjs/useCurrentRender.js.map +1 -1
- package/lib/commonjs/useDescriptors.js +92 -41
- package/lib/commonjs/useDescriptors.js.map +1 -1
- package/lib/commonjs/useEventEmitter.js +6 -7
- package/lib/commonjs/useEventEmitter.js.map +1 -1
- package/lib/commonjs/useFocusEffect.js +7 -6
- package/lib/commonjs/useFocusEffect.js.map +1 -1
- package/lib/commonjs/useFocusEvents.js +7 -8
- package/lib/commonjs/useFocusEvents.js.map +1 -1
- package/lib/commonjs/useFocusedListenersChildrenAdapter.js +6 -7
- package/lib/commonjs/useFocusedListenersChildrenAdapter.js.map +1 -1
- package/lib/commonjs/useIsFocused.js +8 -8
- package/lib/commonjs/useIsFocused.js.map +1 -1
- package/lib/commonjs/useIsomorphicLayoutEffect.js +12 -0
- package/lib/commonjs/useIsomorphicLayoutEffect.js.map +1 -0
- package/lib/commonjs/useIsomorphicLayoutEffect.native.js +9 -0
- package/lib/commonjs/useIsomorphicLayoutEffect.native.js.map +1 -0
- package/lib/commonjs/useKeyedChildListeners.js +3 -3
- package/lib/commonjs/useKeyedChildListeners.js.map +1 -1
- package/lib/commonjs/useNavigation.js +7 -8
- package/lib/commonjs/useNavigation.js.map +1 -1
- package/lib/commonjs/useNavigationBuilder.js +115 -106
- package/lib/commonjs/useNavigationBuilder.js.map +1 -1
- package/lib/commonjs/useNavigationCache.js +60 -20
- package/lib/commonjs/useNavigationCache.js.map +1 -1
- package/lib/commonjs/useNavigationContainerRef.js +5 -6
- package/lib/commonjs/useNavigationContainerRef.js.map +1 -1
- package/lib/commonjs/useNavigationHelpers.js +9 -11
- package/lib/commonjs/useNavigationHelpers.js.map +1 -1
- package/lib/commonjs/useNavigationIndependentTree.js +5 -6
- package/lib/commonjs/useNavigationIndependentTree.js.map +1 -1
- package/lib/commonjs/useNavigationState.js +5 -6
- package/lib/commonjs/useNavigationState.js.map +1 -1
- package/lib/commonjs/useOnAction.js +13 -12
- package/lib/commonjs/useOnAction.js.map +1 -1
- package/lib/commonjs/useOnGetState.js +11 -13
- package/lib/commonjs/useOnGetState.js.map +1 -1
- package/lib/commonjs/useOnPreventRemove.js +10 -12
- package/lib/commonjs/useOnPreventRemove.js.map +1 -1
- package/lib/commonjs/useOnRouteFocus.js +5 -6
- package/lib/commonjs/useOnRouteFocus.js.map +1 -1
- package/lib/commonjs/useOptionsGetters.js +14 -16
- package/lib/commonjs/useOptionsGetters.js.map +1 -1
- package/lib/commonjs/usePreventRemove.js +10 -10
- package/lib/commonjs/usePreventRemove.js.map +1 -1
- package/lib/commonjs/usePreventRemoveContext.js +5 -6
- package/lib/commonjs/usePreventRemoveContext.js.map +1 -1
- package/lib/commonjs/useRegisterNavigator.js +3 -3
- package/lib/commonjs/useRegisterNavigator.js.map +1 -1
- package/lib/commonjs/useRoute.js +5 -6
- package/lib/commonjs/useRoute.js.map +1 -1
- package/lib/commonjs/useRouteCache.js +20 -17
- package/lib/commonjs/useRouteCache.js.map +1 -1
- package/lib/commonjs/useSyncState.js +28 -57
- package/lib/commonjs/useSyncState.js.map +1 -1
- package/lib/commonjs/validatePathConfig.js +38 -11
- package/lib/commonjs/validatePathConfig.js.map +1 -1
- package/lib/module/BaseNavigationContainer.js +39 -44
- package/lib/module/BaseNavigationContainer.js.map +1 -1
- package/lib/module/CurrentRenderContext.js +1 -2
- package/lib/module/CurrentRenderContext.js.map +1 -1
- package/lib/module/DeprecatedNavigationInChildContext.js +1 -2
- package/lib/module/DeprecatedNavigationInChildContext.js.map +1 -1
- package/lib/module/EnsureSingleNavigator.js +1 -1
- package/lib/module/EnsureSingleNavigator.js.map +1 -1
- package/lib/module/Group.js +1 -1
- package/lib/module/Group.js.map +1 -1
- package/lib/module/NavigationBuilderContext.js +1 -2
- package/lib/module/NavigationBuilderContext.js.map +1 -1
- package/lib/module/NavigationContainerRefContext.js +1 -2
- package/lib/module/NavigationContainerRefContext.js.map +1 -1
- package/lib/module/NavigationContext.js +1 -2
- package/lib/module/NavigationContext.js.map +1 -1
- package/lib/module/NavigationHelpersContext.js +1 -2
- package/lib/module/NavigationHelpersContext.js.map +1 -1
- package/lib/module/NavigationIndependentTree.js +4 -4
- package/lib/module/NavigationIndependentTree.js.map +1 -1
- package/lib/module/NavigationIndependentTreeContext.js +1 -2
- package/lib/module/NavigationIndependentTreeContext.js.map +1 -1
- package/lib/module/NavigationRouteContext.js +1 -2
- package/lib/module/NavigationRouteContext.js.map +1 -1
- package/lib/module/NavigationStateContext.js +1 -1
- package/lib/module/NavigationStateContext.js.map +1 -1
- package/lib/module/PreventRemoveContext.js +1 -2
- package/lib/module/PreventRemoveContext.js.map +1 -1
- package/lib/module/PreventRemoveProvider.js +10 -12
- package/lib/module/PreventRemoveProvider.js.map +1 -1
- package/lib/module/SceneView.js +5 -5
- package/lib/module/SceneView.js.map +1 -1
- package/lib/module/Screen.js +1 -1
- package/lib/module/Screen.js.map +1 -1
- package/lib/module/StaticContainer.js +2 -3
- package/lib/module/StaticContainer.js.map +1 -1
- package/lib/module/StaticNavigation.js +28 -6
- package/lib/module/StaticNavigation.js.map +1 -1
- package/lib/module/UnhandledActionContext.js +1 -2
- package/lib/module/UnhandledActionContext.js.map +1 -1
- package/lib/module/checkDuplicateRouteNames.js +2 -3
- package/lib/module/checkDuplicateRouteNames.js.map +1 -1
- package/lib/module/checkSerializable.js +1 -1
- package/lib/module/checkSerializable.js.map +1 -1
- package/lib/module/createNavigationContainerRef.js +1 -1
- package/lib/module/createNavigationContainerRef.js.map +1 -1
- package/lib/module/createNavigatorFactory.js +3 -6
- package/lib/module/createNavigatorFactory.js.map +1 -1
- package/lib/module/findFocusedRoute.js +3 -5
- package/lib/module/findFocusedRoute.js.map +1 -1
- package/lib/module/getActionFromState.js +7 -9
- package/lib/module/getActionFromState.js.map +1 -1
- package/lib/module/getFocusedRouteNameFromRoute.js +2 -2
- package/lib/module/getFocusedRouteNameFromRoute.js.map +1 -1
- package/lib/module/getPathFromState.js +21 -21
- package/lib/module/getPathFromState.js.map +1 -1
- package/lib/module/getStateFromPath.js +25 -18
- package/lib/module/getStateFromPath.js.map +1 -1
- package/lib/module/index.js +31 -28
- package/lib/module/index.js.map +1 -1
- package/lib/module/isArrayEqual.js +1 -1
- package/lib/module/isArrayEqual.js.map +1 -1
- package/lib/module/isRecordEqual.js +1 -1
- package/lib/module/isRecordEqual.js.map +1 -1
- package/lib/module/theming/ThemeContext.js +4 -0
- package/lib/module/theming/ThemeContext.js.map +1 -0
- package/lib/module/theming/ThemeProvider.js +12 -0
- package/lib/module/theming/ThemeProvider.js.map +1 -0
- package/lib/module/theming/useTheme.js +10 -0
- package/lib/module/theming/useTheme.js.map +1 -0
- package/lib/module/types.js +1 -8
- package/lib/module/types.js.map +1 -1
- package/lib/module/useChildListeners.js +1 -1
- package/lib/module/useChildListeners.js.map +1 -1
- package/lib/module/useComponent.js +1 -1
- package/lib/module/useComponent.js.map +1 -1
- package/lib/module/useCurrentRender.js +2 -2
- package/lib/module/useCurrentRender.js.map +1 -1
- package/lib/module/useDescriptors.js +88 -36
- package/lib/module/useDescriptors.js.map +1 -1
- package/lib/module/useEventEmitter.js +4 -5
- package/lib/module/useEventEmitter.js.map +1 -1
- package/lib/module/useFocusEffect.js +4 -2
- package/lib/module/useFocusEffect.js.map +1 -1
- package/lib/module/useFocusEvents.js +4 -4
- package/lib/module/useFocusEvents.js.map +1 -1
- package/lib/module/useFocusedListenersChildrenAdapter.js +3 -3
- package/lib/module/useFocusedListenersChildrenAdapter.js.map +1 -1
- package/lib/module/useIsFocused.js +2 -2
- package/lib/module/useIsFocused.js.map +1 -1
- package/lib/module/useIsomorphicLayoutEffect.js +7 -0
- package/lib/module/useIsomorphicLayoutEffect.js.map +1 -0
- package/lib/module/useIsomorphicLayoutEffect.native.js +3 -0
- package/lib/module/useIsomorphicLayoutEffect.native.js.map +1 -0
- package/lib/module/useKeyedChildListeners.js +1 -1
- package/lib/module/useKeyedChildListeners.js.map +1 -1
- package/lib/module/useNavigation.js +3 -3
- package/lib/module/useNavigation.js.map +1 -1
- package/lib/module/useNavigationBuilder.js +97 -88
- package/lib/module/useNavigationBuilder.js.map +1 -1
- package/lib/module/useNavigationCache.js +57 -16
- package/lib/module/useNavigationCache.js.map +1 -1
- package/lib/module/useNavigationContainerRef.js +2 -2
- package/lib/module/useNavigationContainerRef.js.map +1 -1
- package/lib/module/useNavigationHelpers.js +5 -6
- package/lib/module/useNavigationHelpers.js.map +1 -1
- package/lib/module/useNavigationIndependentTree.js +2 -2
- package/lib/module/useNavigationIndependentTree.js.map +1 -1
- package/lib/module/useNavigationState.js +2 -2
- package/lib/module/useNavigationState.js.map +1 -1
- package/lib/module/useOnAction.js +8 -6
- package/lib/module/useOnAction.js.map +1 -1
- package/lib/module/useOnGetState.js +6 -7
- package/lib/module/useOnGetState.js.map +1 -1
- package/lib/module/useOnPreventRemove.js +6 -7
- package/lib/module/useOnPreventRemove.js.map +1 -1
- package/lib/module/useOnRouteFocus.js +2 -2
- package/lib/module/useOnRouteFocus.js.map +1 -1
- package/lib/module/useOptionsGetters.js +10 -11
- package/lib/module/useOptionsGetters.js.map +1 -1
- package/lib/module/usePreventRemove.js +5 -5
- package/lib/module/usePreventRemove.js.map +1 -1
- package/lib/module/usePreventRemoveContext.js +2 -2
- package/lib/module/usePreventRemoveContext.js.map +1 -1
- package/lib/module/useRegisterNavigator.js +1 -1
- package/lib/module/useRegisterNavigator.js.map +1 -1
- package/lib/module/useRoute.js +2 -2
- package/lib/module/useRoute.js.map +1 -1
- package/lib/module/useRouteCache.js +17 -13
- package/lib/module/useRouteCache.js.map +1 -1
- package/lib/module/useSyncState.js +25 -54
- package/lib/module/useSyncState.js.map +1 -1
- package/lib/module/validatePathConfig.js +38 -11
- package/lib/module/validatePathConfig.js.map +1 -1
- package/lib/typescript/src/BaseNavigationContainer.d.ts +3 -3
- package/lib/typescript/src/BaseNavigationContainer.d.ts.map +1 -1
- package/lib/typescript/src/CurrentRenderContext.d.ts +1 -2
- package/lib/typescript/src/CurrentRenderContext.d.ts.map +1 -1
- package/lib/typescript/src/DeprecatedNavigationInChildContext.d.ts +1 -2
- package/lib/typescript/src/DeprecatedNavigationInChildContext.d.ts.map +1 -1
- package/lib/typescript/src/EnsureSingleNavigator.d.ts +1 -1
- package/lib/typescript/src/EnsureSingleNavigator.d.ts.map +1 -1
- package/lib/typescript/src/Group.d.ts +1 -1
- package/lib/typescript/src/Group.d.ts.map +1 -1
- package/lib/typescript/src/NavigationBuilderContext.d.ts +1 -2
- package/lib/typescript/src/NavigationBuilderContext.d.ts.map +1 -1
- package/lib/typescript/src/NavigationContainerRefContext.d.ts +1 -2
- package/lib/typescript/src/NavigationContainerRefContext.d.ts.map +1 -1
- package/lib/typescript/src/NavigationContext.d.ts +1 -18
- package/lib/typescript/src/NavigationContext.d.ts.map +1 -1
- package/lib/typescript/src/NavigationHelpersContext.d.ts +1 -2
- package/lib/typescript/src/NavigationHelpersContext.d.ts.map +1 -1
- package/lib/typescript/src/NavigationIndependentTree.d.ts +2 -2
- package/lib/typescript/src/NavigationIndependentTree.d.ts.map +1 -1
- package/lib/typescript/src/NavigationIndependentTreeContext.d.ts +1 -2
- package/lib/typescript/src/NavigationIndependentTreeContext.d.ts.map +1 -1
- package/lib/typescript/src/NavigationRouteContext.d.ts +1 -2
- package/lib/typescript/src/NavigationRouteContext.d.ts.map +1 -1
- package/lib/typescript/src/NavigationStateContext.d.ts +3 -20
- package/lib/typescript/src/NavigationStateContext.d.ts.map +1 -1
- package/lib/typescript/src/PreventRemoveContext.d.ts +1 -2
- package/lib/typescript/src/PreventRemoveContext.d.ts.map +1 -1
- package/lib/typescript/src/PreventRemoveProvider.d.ts +1 -1
- package/lib/typescript/src/PreventRemoveProvider.d.ts.map +1 -1
- package/lib/typescript/src/SceneView.d.ts +2 -2
- package/lib/typescript/src/SceneView.d.ts.map +1 -1
- package/lib/typescript/src/Screen.d.ts +1 -1
- package/lib/typescript/src/Screen.d.ts.map +1 -1
- package/lib/typescript/src/StaticContainer.d.ts +1 -3
- package/lib/typescript/src/StaticContainer.d.ts.map +1 -1
- package/lib/typescript/src/StaticNavigation.d.ts +12 -5
- package/lib/typescript/src/StaticNavigation.d.ts.map +1 -1
- package/lib/typescript/src/UnhandledActionContext.d.ts +1 -2
- package/lib/typescript/src/UnhandledActionContext.d.ts.map +1 -1
- package/lib/typescript/src/checkDuplicateRouteNames.d.ts +1 -1
- package/lib/typescript/src/checkDuplicateRouteNames.d.ts.map +1 -1
- package/lib/typescript/src/checkSerializable.d.ts +1 -1
- package/lib/typescript/src/checkSerializable.d.ts.map +1 -1
- package/lib/typescript/src/createNavigationContainerRef.d.ts +1 -1
- package/lib/typescript/src/createNavigationContainerRef.d.ts.map +1 -1
- package/lib/typescript/src/createNavigatorFactory.d.ts +1 -1
- package/lib/typescript/src/createNavigatorFactory.d.ts.map +1 -1
- package/lib/typescript/src/findFocusedRoute.d.ts +2 -10
- package/lib/typescript/src/findFocusedRoute.d.ts.map +1 -1
- package/lib/typescript/src/getActionFromState.d.ts +1 -1
- package/lib/typescript/src/getActionFromState.d.ts.map +1 -1
- package/lib/typescript/src/getFocusedRouteNameFromRoute.d.ts +1 -1
- package/lib/typescript/src/getFocusedRouteNameFromRoute.d.ts.map +1 -1
- package/lib/typescript/src/getPathFromState.d.ts +2 -1
- package/lib/typescript/src/getPathFromState.d.ts.map +1 -1
- package/lib/typescript/src/getStateFromPath.d.ts +2 -1
- package/lib/typescript/src/getStateFromPath.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +31 -28
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/isArrayEqual.d.ts +1 -1
- package/lib/typescript/src/isArrayEqual.d.ts.map +1 -1
- package/lib/typescript/src/isRecordEqual.d.ts +1 -1
- package/lib/typescript/src/isRecordEqual.d.ts.map +1 -1
- package/lib/typescript/src/theming/ThemeContext.d.ts +3 -0
- package/lib/typescript/src/theming/ThemeContext.d.ts.map +1 -0
- package/lib/typescript/src/theming/ThemeProvider.d.ts +8 -0
- package/lib/typescript/src/theming/ThemeProvider.d.ts.map +1 -0
- package/lib/typescript/src/theming/useTheme.d.ts +2 -0
- package/lib/typescript/src/theming/useTheme.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +80 -1
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/useChildListeners.d.ts +1 -1
- package/lib/typescript/src/useChildListeners.d.ts.map +1 -1
- package/lib/typescript/src/useComponent.d.ts +2 -2
- package/lib/typescript/src/useComponent.d.ts.map +1 -1
- package/lib/typescript/src/useCurrentRender.d.ts +1 -1
- package/lib/typescript/src/useCurrentRender.d.ts.map +1 -1
- package/lib/typescript/src/useDescriptors.d.ts +107 -59
- package/lib/typescript/src/useDescriptors.d.ts.map +1 -1
- package/lib/typescript/src/useEventEmitter.d.ts +1 -1
- package/lib/typescript/src/useEventEmitter.d.ts.map +1 -1
- package/lib/typescript/src/useFocusEffect.d.ts +1 -1
- package/lib/typescript/src/useFocusEffect.d.ts.map +1 -1
- package/lib/typescript/src/useFocusEvents.d.ts +1 -1
- package/lib/typescript/src/useFocusEvents.d.ts.map +1 -1
- package/lib/typescript/src/useFocusedListenersChildrenAdapter.d.ts +2 -2
- package/lib/typescript/src/useFocusedListenersChildrenAdapter.d.ts.map +1 -1
- package/lib/typescript/src/useIsFocused.d.ts +1 -1
- package/lib/typescript/src/useIsFocused.d.ts.map +1 -1
- package/lib/typescript/src/useIsomorphicLayoutEffect.d.ts +6 -0
- package/lib/typescript/src/useIsomorphicLayoutEffect.d.ts.map +1 -0
- package/lib/typescript/src/useIsomorphicLayoutEffect.native.d.ts +3 -0
- package/lib/typescript/src/useIsomorphicLayoutEffect.native.d.ts.map +1 -0
- package/lib/typescript/src/useKeyedChildListeners.d.ts +1 -1
- package/lib/typescript/src/useKeyedChildListeners.d.ts.map +1 -1
- package/lib/typescript/src/useNavigation.d.ts +4 -1
- package/lib/typescript/src/useNavigation.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationBuilder.d.ts +99 -63
- package/lib/typescript/src/useNavigationBuilder.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationCache.d.ts +53 -3
- package/lib/typescript/src/useNavigationCache.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationContainerRef.d.ts +1 -1
- package/lib/typescript/src/useNavigationContainerRef.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationHelpers.d.ts +26 -40
- package/lib/typescript/src/useNavigationHelpers.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationIndependentTree.d.ts +1 -1
- package/lib/typescript/src/useNavigationIndependentTree.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationState.d.ts +1 -1
- package/lib/typescript/src/useNavigationState.d.ts.map +1 -1
- package/lib/typescript/src/useOnAction.d.ts +2 -2
- package/lib/typescript/src/useOnAction.d.ts.map +1 -1
- package/lib/typescript/src/useOnGetState.d.ts +2 -2
- package/lib/typescript/src/useOnGetState.d.ts.map +1 -1
- package/lib/typescript/src/useOnPreventRemove.d.ts +2 -2
- package/lib/typescript/src/useOnPreventRemove.d.ts.map +1 -1
- package/lib/typescript/src/useOnRouteFocus.d.ts +1 -1
- package/lib/typescript/src/useOnRouteFocus.d.ts.map +1 -1
- package/lib/typescript/src/useOptionsGetters.d.ts +1 -1
- package/lib/typescript/src/useOptionsGetters.d.ts.map +1 -1
- package/lib/typescript/src/usePreventRemove.d.ts +1 -1
- package/lib/typescript/src/usePreventRemove.d.ts.map +1 -1
- package/lib/typescript/src/usePreventRemoveContext.d.ts +1 -1
- package/lib/typescript/src/usePreventRemoveContext.d.ts.map +1 -1
- package/lib/typescript/src/useRegisterNavigator.d.ts +1 -1
- package/lib/typescript/src/useRegisterNavigator.d.ts.map +1 -1
- package/lib/typescript/src/useRoute.d.ts +1 -1
- package/lib/typescript/src/useRoute.d.ts.map +1 -1
- package/lib/typescript/src/useRouteCache.d.ts +1 -1
- package/lib/typescript/src/useRouteCache.d.ts.map +1 -1
- package/lib/typescript/src/useSyncState.d.ts +1 -4
- package/lib/typescript/src/useSyncState.d.ts.map +1 -1
- package/lib/typescript/src/validatePathConfig.d.ts +1 -1
- package/lib/typescript/src/validatePathConfig.d.ts.map +1 -1
- package/lib/typescript/utils/usePrevious.d.ts +6 -0
- package/lib/typescript/utils/usePrevious.d.ts.map +1 -0
- package/package.json +14 -14
- package/src/BaseNavigationContainer.tsx +52 -55
- package/src/CurrentRenderContext.tsx +1 -3
- package/src/DeprecatedNavigationInChildContext.tsx +1 -3
- package/src/EnsureSingleNavigator.tsx +1 -1
- package/src/Group.tsx +2 -2
- package/src/NavigationBuilderContext.tsx +1 -3
- package/src/NavigationContainerRefContext.tsx +1 -3
- package/src/NavigationContext.tsx +1 -3
- package/src/NavigationHelpersContext.tsx +1 -3
- package/src/NavigationIndependentTree.tsx +4 -4
- package/src/NavigationIndependentTreeContext.tsx +1 -3
- package/src/NavigationRouteContext.tsx +3 -5
- package/src/NavigationStateContext.tsx +1 -1
- package/src/PreventRemoveContext.tsx +1 -3
- package/src/PreventRemoveProvider.tsx +7 -4
- package/src/SceneView.tsx +6 -6
- package/src/Screen.tsx +2 -2
- package/src/StaticContainer.tsx +19 -18
- package/src/StaticNavigation.tsx +35 -33
- package/src/UnhandledActionContext.tsx +1 -3
- package/src/checkDuplicateRouteNames.tsx +2 -2
- package/src/checkSerializable.tsx +1 -1
- package/src/createNavigationContainerRef.tsx +2 -2
- package/src/createNavigatorFactory.tsx +5 -7
- package/src/findFocusedRoute.tsx +1 -1
- package/src/getActionFromState.tsx +2 -2
- package/src/getFocusedRouteNameFromRoute.tsx +4 -4
- package/src/getPathFromState.tsx +16 -13
- package/src/getStateFromPath.tsx +25 -6
- package/src/index.tsx +33 -30
- package/src/isArrayEqual.tsx +1 -1
- package/src/isRecordEqual.tsx +1 -4
- package/src/theming/ThemeContext.tsx +7 -0
- package/src/theming/ThemeProvider.tsx +14 -0
- package/src/theming/useTheme.tsx +15 -0
- package/src/types.tsx +133 -17
- package/src/useChildListeners.tsx +1 -1
- package/src/useComponent.tsx +1 -1
- package/src/useCurrentRender.tsx +2 -6
- package/src/useDescriptors.tsx +161 -66
- package/src/useEventEmitter.tsx +1 -1
- package/src/useFocusEffect.tsx +3 -2
- package/src/useFocusEvents.tsx +2 -2
- package/src/useFocusedListenersChildrenAdapter.tsx +5 -4
- package/src/useIsFocused.tsx +2 -2
- package/src/useIsomorphicLayoutEffect.native.tsx +3 -0
- package/src/useIsomorphicLayoutEffect.tsx +7 -0
- package/src/useKeyedChildListeners.tsx +1 -1
- package/src/useNavigation.tsx +7 -4
- package/src/useNavigationBuilder.tsx +141 -122
- package/src/useNavigationCache.tsx +93 -32
- package/src/useNavigationContainerRef.tsx +3 -3
- package/src/useNavigationHelpers.tsx +9 -10
- package/src/useNavigationIndependentTree.tsx +2 -2
- package/src/useNavigationState.tsx +2 -2
- package/src/useOnAction.tsx +13 -7
- package/src/useOnGetState.tsx +6 -8
- package/src/useOnPreventRemove.tsx +5 -4
- package/src/useOnRouteFocus.tsx +2 -2
- package/src/useOptionsGetters.tsx +5 -9
- package/src/usePreventRemove.tsx +4 -4
- package/src/usePreventRemoveContext.tsx +2 -2
- package/src/useRegisterNavigator.tsx +1 -1
- package/src/useRoute.tsx +2 -2
- package/src/useRouteCache.tsx +18 -17
- package/src/useSyncState.tsx +31 -59
- package/src/validatePathConfig.tsx +58 -14
- package/lib/commonjs/fromEntries.js +0 -18
- package/lib/commonjs/fromEntries.js.map +0 -1
- package/lib/commonjs/useScheduleUpdate.js +0 -37
- package/lib/commonjs/useScheduleUpdate.js.map +0 -1
- package/lib/module/fromEntries.js +0 -12
- package/lib/module/fromEntries.js.map +0 -1
- package/lib/module/useScheduleUpdate.js +0 -27
- package/lib/module/useScheduleUpdate.js.map +0 -1
- package/lib/typescript/src/fromEntries.d.ts +0 -2
- package/lib/typescript/src/fromEntries.d.ts.map +0 -1
- package/lib/typescript/src/useScheduleUpdate.d.ts +0 -14
- package/lib/typescript/src/useScheduleUpdate.d.ts.map +0 -1
- package/src/fromEntries.tsx +0 -13
- package/src/useScheduleUpdate.tsx +0 -32
package/src/useDescriptors.tsx
CHANGED
|
@@ -2,17 +2,20 @@ import type {
|
|
|
2
2
|
NavigationAction,
|
|
3
3
|
NavigationState,
|
|
4
4
|
ParamListBase,
|
|
5
|
+
PartialState,
|
|
5
6
|
Router,
|
|
6
7
|
} from '@react-navigation/routers';
|
|
7
8
|
import * as React from 'react';
|
|
8
9
|
|
|
9
|
-
import
|
|
10
|
-
AddKeyedListener,
|
|
11
|
-
AddListener,
|
|
10
|
+
import {
|
|
11
|
+
type AddKeyedListener,
|
|
12
|
+
type AddListener,
|
|
13
|
+
NavigationBuilderContext,
|
|
12
14
|
} from './NavigationBuilderContext';
|
|
13
|
-
import NavigationContext from './NavigationContext';
|
|
14
|
-
import NavigationRouteContext from './NavigationRouteContext';
|
|
15
|
-
import SceneView from './SceneView';
|
|
15
|
+
import { NavigationContext } from './NavigationContext';
|
|
16
|
+
import { NavigationRouteContext } from './NavigationRouteContext';
|
|
17
|
+
import { SceneView } from './SceneView';
|
|
18
|
+
import { ThemeContext } from './theming/ThemeContext';
|
|
16
19
|
import type {
|
|
17
20
|
Descriptor,
|
|
18
21
|
EventMapBase,
|
|
@@ -22,30 +25,39 @@ import type {
|
|
|
22
25
|
RouteProp,
|
|
23
26
|
} from './types';
|
|
24
27
|
import type { NavigationEventEmitter } from './useEventEmitter';
|
|
25
|
-
import useNavigationCache from './useNavigationCache';
|
|
26
|
-
import useRouteCache from './useRouteCache';
|
|
28
|
+
import { useNavigationCache } from './useNavigationCache';
|
|
29
|
+
import { useRouteCache } from './useRouteCache';
|
|
27
30
|
|
|
28
31
|
export type ScreenConfigWithParent<
|
|
29
32
|
State extends NavigationState,
|
|
30
33
|
ScreenOptions extends {},
|
|
31
|
-
EventMap extends EventMapBase
|
|
34
|
+
EventMap extends EventMapBase,
|
|
32
35
|
> = {
|
|
33
36
|
keys: (string | undefined)[];
|
|
34
37
|
options: (ScreenOptionsOrCallback<ScreenOptions> | undefined)[] | undefined;
|
|
38
|
+
layout: ScreenLayout | undefined;
|
|
35
39
|
props: RouteConfig<ParamListBase, string, State, ScreenOptions, EventMap>;
|
|
36
40
|
};
|
|
37
41
|
|
|
42
|
+
type ScreenLayout = (props: {
|
|
43
|
+
route: RouteProp<ParamListBase, string>;
|
|
44
|
+
navigation: any;
|
|
45
|
+
theme: ReactNavigation.Theme;
|
|
46
|
+
children: React.ReactElement;
|
|
47
|
+
}) => React.ReactElement;
|
|
48
|
+
|
|
38
49
|
type ScreenOptionsOrCallback<ScreenOptions extends {}> =
|
|
39
50
|
| ScreenOptions
|
|
40
51
|
| ((props: {
|
|
41
52
|
route: RouteProp<ParamListBase, string>;
|
|
42
53
|
navigation: any;
|
|
54
|
+
theme: ReactNavigation.Theme;
|
|
43
55
|
}) => ScreenOptions);
|
|
44
56
|
|
|
45
57
|
type Options<
|
|
46
58
|
State extends NavigationState,
|
|
47
59
|
ScreenOptions extends {},
|
|
48
|
-
EventMap extends EventMapBase
|
|
60
|
+
EventMap extends EventMapBase,
|
|
49
61
|
> = {
|
|
50
62
|
state: State;
|
|
51
63
|
screens: Record<
|
|
@@ -53,14 +65,8 @@ type Options<
|
|
|
53
65
|
ScreenConfigWithParent<State, ScreenOptions, EventMap>
|
|
54
66
|
>;
|
|
55
67
|
navigation: NavigationHelpers<ParamListBase>;
|
|
56
|
-
screenOptions
|
|
57
|
-
|
|
58
|
-
| ScreenOptions
|
|
59
|
-
| ((props: {
|
|
60
|
-
route: RouteProp<ParamListBase>;
|
|
61
|
-
navigation: any;
|
|
62
|
-
options: ScreenOptions;
|
|
63
|
-
}) => ScreenOptions);
|
|
68
|
+
screenOptions: ScreenOptionsOrCallback<ScreenOptions> | undefined;
|
|
69
|
+
screenLayout: ScreenLayout | undefined;
|
|
64
70
|
onAction: (action: NavigationAction) => boolean;
|
|
65
71
|
getState: () => State;
|
|
66
72
|
setState: (state: State) => void;
|
|
@@ -79,17 +85,17 @@ type Options<
|
|
|
79
85
|
* - Options specified by the screen for the navigator
|
|
80
86
|
* - Navigation object intended for the route
|
|
81
87
|
*/
|
|
82
|
-
export
|
|
88
|
+
export function useDescriptors<
|
|
83
89
|
State extends NavigationState,
|
|
84
90
|
ActionHelpers extends Record<string, () => void>,
|
|
85
91
|
ScreenOptions extends {},
|
|
86
|
-
EventMap extends EventMapBase
|
|
92
|
+
EventMap extends EventMapBase,
|
|
87
93
|
>({
|
|
88
94
|
state,
|
|
89
95
|
screens,
|
|
90
96
|
navigation,
|
|
91
97
|
screenOptions,
|
|
92
|
-
|
|
98
|
+
screenLayout,
|
|
93
99
|
onAction,
|
|
94
100
|
getState,
|
|
95
101
|
setState,
|
|
@@ -99,6 +105,7 @@ export default function useDescriptors<
|
|
|
99
105
|
router,
|
|
100
106
|
emitter,
|
|
101
107
|
}: Options<State, ScreenOptions, EventMap>) {
|
|
108
|
+
const theme = React.useContext(ThemeContext);
|
|
102
109
|
const [options, setOptions] = React.useState<Record<string, ScreenOptions>>(
|
|
103
110
|
{}
|
|
104
111
|
);
|
|
@@ -129,7 +136,12 @@ export default function useDescriptors<
|
|
|
129
136
|
]
|
|
130
137
|
);
|
|
131
138
|
|
|
132
|
-
const navigations = useNavigationCache<
|
|
139
|
+
const { base, navigations } = useNavigationCache<
|
|
140
|
+
State,
|
|
141
|
+
ScreenOptions,
|
|
142
|
+
EventMap,
|
|
143
|
+
ActionHelpers
|
|
144
|
+
>({
|
|
133
145
|
state,
|
|
134
146
|
getState,
|
|
135
147
|
navigation,
|
|
@@ -140,27 +152,20 @@ export default function useDescriptors<
|
|
|
140
152
|
|
|
141
153
|
const routes = useRouteCache(state.routes);
|
|
142
154
|
|
|
143
|
-
|
|
144
|
-
|
|
155
|
+
const getOptions = (
|
|
156
|
+
route: RouteProp<ParamListBase, string>,
|
|
157
|
+
navigation: NavigationProp<
|
|
158
|
+
ParamListBase,
|
|
145
159
|
string,
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
ScreenOptions,
|
|
154
|
-
EventMap
|
|
155
|
-
> &
|
|
156
|
-
ActionHelpers,
|
|
157
|
-
RouteProp<ParamListBase>
|
|
158
|
-
>
|
|
159
|
-
>
|
|
160
|
-
>((acc, route, i) => {
|
|
160
|
+
string | undefined,
|
|
161
|
+
State,
|
|
162
|
+
ScreenOptions,
|
|
163
|
+
EventMap
|
|
164
|
+
>,
|
|
165
|
+
overrides: Record<string, ScreenOptions>
|
|
166
|
+
) => {
|
|
161
167
|
const config = screens[route.name];
|
|
162
168
|
const screen = config.props;
|
|
163
|
-
const navigation = navigations[route.key];
|
|
164
169
|
|
|
165
170
|
const optionsList = [
|
|
166
171
|
// The default `screenOptions` passed to the navigator
|
|
@@ -172,30 +177,35 @@ export default function useDescriptors<
|
|
|
172
177
|
// The `options` prop passed to `Screen` elements,
|
|
173
178
|
screen.options,
|
|
174
179
|
// The options set via `navigation.setOptions`
|
|
175
|
-
|
|
180
|
+
overrides,
|
|
176
181
|
];
|
|
177
182
|
|
|
178
|
-
|
|
183
|
+
return optionsList.reduce<ScreenOptions>(
|
|
179
184
|
(acc, curr) =>
|
|
180
185
|
Object.assign(
|
|
181
186
|
acc,
|
|
182
187
|
// @ts-expect-error: we check for function but TS still complains
|
|
183
|
-
typeof curr !== 'function' ? curr : curr({ route, navigation })
|
|
188
|
+
typeof curr !== 'function' ? curr : curr({ route, navigation, theme })
|
|
184
189
|
),
|
|
185
190
|
{} as ScreenOptions
|
|
186
191
|
);
|
|
192
|
+
};
|
|
187
193
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
194
|
+
const render = (
|
|
195
|
+
route: RouteProp<ParamListBase, string>,
|
|
196
|
+
navigation: NavigationProp<
|
|
197
|
+
ParamListBase,
|
|
198
|
+
string,
|
|
199
|
+
string | undefined,
|
|
200
|
+
State,
|
|
201
|
+
ScreenOptions,
|
|
202
|
+
EventMap
|
|
203
|
+
>,
|
|
204
|
+
customOptions: ScreenOptions,
|
|
205
|
+
routeState: NavigationState | PartialState<NavigationState> | undefined
|
|
206
|
+
) => {
|
|
207
|
+
const config = screens[route.name];
|
|
208
|
+
const screen = config.props;
|
|
199
209
|
|
|
200
210
|
const clearOptions = () =>
|
|
201
211
|
setOptions((o) => {
|
|
@@ -208,24 +218,74 @@ export default function useDescriptors<
|
|
|
208
218
|
return o;
|
|
209
219
|
});
|
|
210
220
|
|
|
211
|
-
const
|
|
221
|
+
const layout =
|
|
222
|
+
// The `layout` prop passed to `Screen` elements,
|
|
223
|
+
screen.layout ??
|
|
224
|
+
// The `screenLayout` props passed to `Group` elements
|
|
225
|
+
config.layout ??
|
|
226
|
+
// The default `screenLayout` passed to the navigator
|
|
227
|
+
screenLayout;
|
|
228
|
+
|
|
229
|
+
let element = (
|
|
230
|
+
<SceneView
|
|
231
|
+
navigation={navigation}
|
|
232
|
+
route={route}
|
|
233
|
+
screen={screen}
|
|
234
|
+
routeState={routeState}
|
|
235
|
+
getState={getState}
|
|
236
|
+
setState={setState}
|
|
237
|
+
options={customOptions}
|
|
238
|
+
clearOptions={clearOptions}
|
|
239
|
+
/>
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
if (layout != null) {
|
|
243
|
+
element = layout({
|
|
244
|
+
route,
|
|
245
|
+
navigation,
|
|
246
|
+
// @ts-expect-error: in practice `theme` will be defined
|
|
247
|
+
theme,
|
|
248
|
+
children: element,
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
return (
|
|
212
253
|
<NavigationBuilderContext.Provider key={route.key} value={context}>
|
|
213
254
|
<NavigationContext.Provider value={navigation}>
|
|
214
255
|
<NavigationRouteContext.Provider value={route}>
|
|
215
|
-
|
|
216
|
-
navigation={navigation}
|
|
217
|
-
route={route}
|
|
218
|
-
screen={screen}
|
|
219
|
-
routeState={state.routes[i].state}
|
|
220
|
-
getState={getState}
|
|
221
|
-
setState={setState}
|
|
222
|
-
options={mergedOptions}
|
|
223
|
-
clearOptions={clearOptions}
|
|
224
|
-
/>
|
|
256
|
+
{element}
|
|
225
257
|
</NavigationRouteContext.Provider>
|
|
226
258
|
</NavigationContext.Provider>
|
|
227
259
|
</NavigationBuilderContext.Provider>
|
|
228
260
|
);
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
const descriptors = routes.reduce<
|
|
264
|
+
Record<
|
|
265
|
+
string,
|
|
266
|
+
Descriptor<
|
|
267
|
+
ScreenOptions,
|
|
268
|
+
NavigationProp<
|
|
269
|
+
ParamListBase,
|
|
270
|
+
string,
|
|
271
|
+
string | undefined,
|
|
272
|
+
State,
|
|
273
|
+
ScreenOptions,
|
|
274
|
+
EventMap
|
|
275
|
+
> &
|
|
276
|
+
ActionHelpers,
|
|
277
|
+
RouteProp<ParamListBase>
|
|
278
|
+
>
|
|
279
|
+
>
|
|
280
|
+
>((acc, route, i) => {
|
|
281
|
+
const navigation = navigations[route.key];
|
|
282
|
+
const customOptions = getOptions(route, navigation, options[route.key]);
|
|
283
|
+
const element = render(
|
|
284
|
+
route,
|
|
285
|
+
navigation,
|
|
286
|
+
customOptions,
|
|
287
|
+
state.routes[i].state
|
|
288
|
+
);
|
|
229
289
|
|
|
230
290
|
acc[route.key] = {
|
|
231
291
|
route,
|
|
@@ -234,9 +294,44 @@ export default function useDescriptors<
|
|
|
234
294
|
render() {
|
|
235
295
|
return element;
|
|
236
296
|
},
|
|
237
|
-
options:
|
|
297
|
+
options: customOptions as ScreenOptions,
|
|
238
298
|
};
|
|
239
299
|
|
|
240
300
|
return acc;
|
|
241
301
|
}, {});
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Create a descriptor object for a route.
|
|
305
|
+
*
|
|
306
|
+
* @param route Route object for which the descriptor should be created
|
|
307
|
+
* @param placeholder Whether the descriptor should be a placeholder, e.g. for a route not yet in the state
|
|
308
|
+
* @returns Descriptor object
|
|
309
|
+
*/
|
|
310
|
+
const describe = (route: RouteProp<ParamListBase>, placeholder: boolean) => {
|
|
311
|
+
if (!placeholder) {
|
|
312
|
+
if (!(route.key in descriptors)) {
|
|
313
|
+
throw new Error(`Couldn't find a route with the key ${route.key}.`);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return descriptors[route.key];
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
const navigation = base;
|
|
320
|
+
const customOptions = getOptions(route, navigation, {});
|
|
321
|
+
const element = render(route, navigation, customOptions, undefined);
|
|
322
|
+
|
|
323
|
+
return {
|
|
324
|
+
route,
|
|
325
|
+
navigation,
|
|
326
|
+
render() {
|
|
327
|
+
return element;
|
|
328
|
+
},
|
|
329
|
+
options: customOptions as ScreenOptions,
|
|
330
|
+
};
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
return {
|
|
334
|
+
describe,
|
|
335
|
+
descriptors,
|
|
336
|
+
};
|
|
242
337
|
}
|
package/src/useEventEmitter.tsx
CHANGED
|
@@ -12,7 +12,7 @@ type Listeners = ((e: any) => void)[];
|
|
|
12
12
|
/**
|
|
13
13
|
* Hook to manage the event system used by the navigator to notify screens of various events.
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export function useEventEmitter<T extends Record<string, any>>(
|
|
16
16
|
listen?: (e: any) => void
|
|
17
17
|
): NavigationEventEmitter<T> {
|
|
18
18
|
const listenRef = React.useRef(listen);
|
package/src/useFocusEffect.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
import useNavigation from './useNavigation';
|
|
3
|
+
import { useNavigation } from './useNavigation';
|
|
4
4
|
|
|
5
5
|
type EffectCallback = () => undefined | void | (() => void);
|
|
6
6
|
|
|
@@ -11,9 +11,10 @@ type EffectCallback = () => undefined | void | (() => void);
|
|
|
11
11
|
*
|
|
12
12
|
* @param callback Memoized callback containing the effect, should optionally return a cleanup function.
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
14
|
+
export function useFocusEffect(effect: EffectCallback) {
|
|
15
15
|
const navigation = useNavigation();
|
|
16
16
|
|
|
17
|
+
// eslint-disable-next-line prefer-rest-params
|
|
17
18
|
if (arguments[1] !== undefined) {
|
|
18
19
|
const message =
|
|
19
20
|
"You passed a second argument to 'useFocusEffect', but it only accepts one argument. " +
|
package/src/useFocusEvents.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { NavigationState } from '@react-navigation/routers';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
|
|
4
|
-
import NavigationContext from './NavigationContext';
|
|
4
|
+
import { NavigationContext } from './NavigationContext';
|
|
5
5
|
import type { EventMapCore } from './types';
|
|
6
6
|
import type { NavigationEventEmitter } from './useEventEmitter';
|
|
7
7
|
|
|
@@ -13,7 +13,7 @@ type Options<State extends NavigationState> = {
|
|
|
13
13
|
/**
|
|
14
14
|
* Hook to take care of emitting `focus` and `blur` events.
|
|
15
15
|
*/
|
|
16
|
-
export
|
|
16
|
+
export function useFocusEvents<State extends NavigationState>({
|
|
17
17
|
state,
|
|
18
18
|
emitter,
|
|
19
19
|
}: Options<State>) {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { ParamListBase } from '@react-navigation/routers';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
FocusedNavigationCallback,
|
|
6
|
-
FocusedNavigationListener,
|
|
4
|
+
import {
|
|
5
|
+
type FocusedNavigationCallback,
|
|
6
|
+
type FocusedNavigationListener,
|
|
7
|
+
NavigationBuilderContext,
|
|
7
8
|
} from './NavigationBuilderContext';
|
|
8
9
|
import type { NavigationHelpers } from './types';
|
|
9
10
|
|
|
@@ -15,7 +16,7 @@ type Options = {
|
|
|
15
16
|
/**
|
|
16
17
|
* Hook for passing focus callback to children
|
|
17
18
|
*/
|
|
18
|
-
export
|
|
19
|
+
export function useFocusedListenersChildrenAdapter({
|
|
19
20
|
navigation,
|
|
20
21
|
focusedListeners,
|
|
21
22
|
}: Options) {
|
package/src/useIsFocused.tsx
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
|
|
4
|
-
import useNavigation from './useNavigation';
|
|
4
|
+
import { useNavigation } from './useNavigation';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Hook to get the current focus state of the screen. Returns a `true` if screen is focused, otherwise `false`.
|
|
8
8
|
* This can be used if a component needs to render something based on the focus state.
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export function useIsFocused(): boolean {
|
|
11
11
|
const navigation = useNavigation();
|
|
12
12
|
const [isFocused, setIsFocused] = useState(navigation.isFocused);
|
|
13
13
|
|
|
@@ -5,7 +5,7 @@ import type { KeyedListenerMap } from './NavigationBuilderContext';
|
|
|
5
5
|
/**
|
|
6
6
|
* Hook which lets child navigators add getters to be called for obtaining rehydrated state.
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export function useKeyedChildListeners() {
|
|
9
9
|
const { current: keyedListeners } = React.useRef<{
|
|
10
10
|
[K in keyof KeyedListenerMap]: Record<
|
|
11
11
|
string,
|
package/src/useNavigation.tsx
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { type NavigationState } from '@react-navigation/routers';
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
|
|
3
|
-
import NavigationContainerRefContext from './NavigationContainerRefContext';
|
|
4
|
-
import NavigationContext from './NavigationContext';
|
|
4
|
+
import { NavigationContainerRefContext } from './NavigationContainerRefContext';
|
|
5
|
+
import { NavigationContext } from './NavigationContext';
|
|
5
6
|
import type { NavigationProp } from './types';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -9,8 +10,10 @@ import type { NavigationProp } from './types';
|
|
|
9
10
|
*
|
|
10
11
|
* @returns Navigation prop of the parent screen.
|
|
11
12
|
*/
|
|
12
|
-
export
|
|
13
|
-
T = NavigationProp<ReactNavigation.RootParamList>
|
|
13
|
+
export function useNavigation<
|
|
14
|
+
T = Omit<NavigationProp<ReactNavigation.RootParamList>, 'getState'> & {
|
|
15
|
+
getState(): NavigationState | undefined;
|
|
16
|
+
},
|
|
14
17
|
>(): T {
|
|
15
18
|
const root = React.useContext(NavigationContainerRefContext);
|
|
16
19
|
const navigation = React.useContext(NavigationContext);
|