@react-navigation/core 6.4.8 → 7.0.0-alpha.1
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/README.md +1 -1
- package/lib/commonjs/BaseNavigationContainer.js +71 -61
- package/lib/commonjs/BaseNavigationContainer.js.map +1 -1
- package/lib/commonjs/CurrentRenderContext.js +2 -3
- package/lib/commonjs/CurrentRenderContext.js.map +1 -1
- package/lib/commonjs/DeprecatedNavigationInChildContext.js +15 -0
- package/lib/commonjs/DeprecatedNavigationInChildContext.js.map +1 -0
- package/lib/commonjs/EnsureSingleNavigator.js +1 -1
- 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 +2 -3
- package/lib/commonjs/NavigationBuilderContext.js.map +1 -1
- package/lib/commonjs/NavigationContainerRefContext.js +2 -3
- package/lib/commonjs/NavigationContainerRefContext.js.map +1 -1
- package/lib/commonjs/NavigationContext.js +2 -3
- package/lib/commonjs/NavigationContext.js.map +1 -1
- package/lib/commonjs/NavigationHelpersContext.js +2 -3
- package/lib/commonjs/NavigationHelpersContext.js.map +1 -1
- package/lib/commonjs/NavigationIndependentTree.js +32 -0
- package/lib/commonjs/NavigationIndependentTree.js.map +1 -0
- package/lib/commonjs/NavigationIndependentTreeContext.js +15 -0
- package/lib/commonjs/NavigationIndependentTreeContext.js.map +1 -0
- package/lib/commonjs/NavigationRouteContext.js +2 -3
- package/lib/commonjs/NavigationRouteContext.js.map +1 -1
- package/lib/commonjs/NavigationStateContext.js +3 -3
- package/lib/commonjs/NavigationStateContext.js.map +1 -1
- package/lib/commonjs/PreventRemoveContext.js +2 -3
- package/lib/commonjs/PreventRemoveContext.js.map +1 -1
- package/lib/commonjs/PreventRemoveProvider.js +8 -8
- package/lib/commonjs/PreventRemoveProvider.js.map +1 -1
- package/lib/commonjs/SceneView.js +8 -9
- 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 +4 -5
- package/lib/commonjs/StaticContainer.js.map +1 -1
- package/lib/commonjs/StaticNavigation.js +159 -0
- package/lib/commonjs/StaticNavigation.js.map +1 -0
- package/lib/commonjs/UnhandledActionContext.js +2 -3
- package/lib/commonjs/UnhandledActionContext.js.map +1 -1
- package/lib/commonjs/checkDuplicateRouteNames.js +1 -1
- 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 +1 -1
- package/lib/commonjs/createNavigationContainerRef.js.map +1 -1
- package/lib/commonjs/createNavigatorFactory.js +19 -11
- package/lib/commonjs/createNavigatorFactory.js.map +1 -1
- package/lib/commonjs/findFocusedRoute.js +1 -1
- package/lib/commonjs/findFocusedRoute.js.map +1 -1
- package/lib/commonjs/fromEntries.js +1 -1
- package/lib/commonjs/fromEntries.js.map +1 -1
- package/lib/commonjs/getActionFromState.js +1 -1
- package/lib/commonjs/getActionFromState.js.map +1 -1
- package/lib/commonjs/getFocusedRouteNameFromRoute.js +1 -1
- package/lib/commonjs/getFocusedRouteNameFromRoute.js.map +1 -1
- package/lib/commonjs/getPathFromState.js +6 -7
- package/lib/commonjs/getPathFromState.js.map +1 -1
- package/lib/commonjs/getStateFromPath.js +5 -5
- package/lib/commonjs/getStateFromPath.js.map +1 -1
- package/lib/commonjs/index.js +83 -53
- 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/useChildListeners.js +1 -1
- package/lib/commonjs/useChildListeners.js.map +1 -1
- package/lib/commonjs/useComponent.js +1 -1
- package/lib/commonjs/useComponent.js.map +1 -1
- package/lib/commonjs/useCurrentRender.js +3 -4
- package/lib/commonjs/useCurrentRender.js.map +1 -1
- package/lib/commonjs/useDescriptors.js +31 -29
- package/lib/commonjs/useDescriptors.js.map +1 -1
- package/lib/commonjs/useEventEmitter.js +1 -1
- package/lib/commonjs/useEventEmitter.js.map +1 -1
- package/lib/commonjs/useFocusEffect.js +3 -4
- package/lib/commonjs/useFocusEffect.js.map +1 -1
- package/lib/commonjs/useFocusEvents.js +3 -4
- package/lib/commonjs/useFocusEvents.js.map +1 -1
- package/lib/commonjs/useFocusedListenersChildrenAdapter.js +3 -4
- package/lib/commonjs/useFocusedListenersChildrenAdapter.js.map +1 -1
- package/lib/commonjs/useIsFocused.js +3 -4
- package/lib/commonjs/useIsFocused.js.map +1 -1
- package/lib/commonjs/useKeyedChildListeners.js +1 -1
- package/lib/commonjs/useKeyedChildListeners.js.map +1 -1
- package/lib/commonjs/useNavigation.js +5 -6
- package/lib/commonjs/useNavigation.js.map +1 -1
- package/lib/commonjs/useNavigationBuilder.js +45 -46
- package/lib/commonjs/useNavigationBuilder.js.map +1 -1
- package/lib/commonjs/useNavigationCache.js +12 -11
- package/lib/commonjs/useNavigationCache.js.map +1 -1
- package/lib/commonjs/useNavigationContainerRef.js +3 -4
- package/lib/commonjs/useNavigationContainerRef.js.map +1 -1
- package/lib/commonjs/useNavigationHelpers.js +5 -6
- package/lib/commonjs/useNavigationHelpers.js.map +1 -1
- package/lib/commonjs/useNavigationIndependentTree.js +14 -0
- package/lib/commonjs/useNavigationIndependentTree.js.map +1 -0
- package/lib/commonjs/useNavigationState.js +3 -4
- package/lib/commonjs/useNavigationState.js.map +1 -1
- package/lib/commonjs/useOnAction.js +16 -13
- package/lib/commonjs/useOnAction.js.map +1 -1
- package/lib/commonjs/useOnGetState.js +7 -8
- package/lib/commonjs/useOnGetState.js.map +1 -1
- package/lib/commonjs/useOnPreventRemove.js +5 -6
- package/lib/commonjs/useOnPreventRemove.js.map +1 -1
- package/lib/commonjs/useOnRouteFocus.js +3 -4
- package/lib/commonjs/useOnRouteFocus.js.map +1 -1
- package/lib/commonjs/useOptionsGetters.js +5 -6
- package/lib/commonjs/useOptionsGetters.js.map +1 -1
- package/lib/commonjs/usePreventRemove.js +8 -8
- package/lib/commonjs/usePreventRemove.js.map +1 -1
- package/lib/commonjs/usePreventRemoveContext.js +3 -4
- package/lib/commonjs/usePreventRemoveContext.js.map +1 -1
- package/lib/commonjs/useRegisterNavigator.js +1 -1
- package/lib/commonjs/useRegisterNavigator.js.map +1 -1
- package/lib/commonjs/useRoute.js +3 -4
- package/lib/commonjs/useRoute.js.map +1 -1
- package/lib/commonjs/useRouteCache.js +1 -1
- package/lib/commonjs/useRouteCache.js.map +1 -1
- package/lib/commonjs/useScheduleUpdate.js +1 -1
- package/lib/commonjs/useScheduleUpdate.js.map +1 -1
- package/lib/commonjs/useSyncState.js +1 -1
- package/lib/commonjs/useSyncState.js.map +1 -1
- package/lib/commonjs/validatePathConfig.js +1 -1
- package/lib/commonjs/validatePathConfig.js.map +1 -1
- package/lib/module/BaseNavigationContainer.js +58 -48
- 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 +7 -0
- package/lib/module/DeprecatedNavigationInChildContext.js.map +1 -0
- 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 +25 -0
- package/lib/module/NavigationIndependentTree.js.map +1 -0
- package/lib/module/NavigationIndependentTreeContext.js +7 -0
- package/lib/module/NavigationIndependentTreeContext.js.map +1 -0
- 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 +4 -4
- 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 +156 -0
- package/lib/module/StaticNavigation.js.map +1 -0
- package/lib/module/UnhandledActionContext.js +1 -2
- package/lib/module/UnhandledActionContext.js.map +1 -1
- package/lib/module/checkDuplicateRouteNames.js +1 -1
- 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 +19 -10
- package/lib/module/createNavigatorFactory.js.map +1 -1
- package/lib/module/findFocusedRoute.js +1 -1
- package/lib/module/findFocusedRoute.js.map +1 -1
- package/lib/module/fromEntries.js +1 -1
- package/lib/module/fromEntries.js.map +1 -1
- package/lib/module/getActionFromState.js +1 -1
- package/lib/module/getActionFromState.js.map +1 -1
- package/lib/module/getFocusedRouteNameFromRoute.js +1 -1
- package/lib/module/getFocusedRouteNameFromRoute.js.map +1 -1
- package/lib/module/getPathFromState.js +3 -3
- package/lib/module/getPathFromState.js.map +1 -1
- package/lib/module/getStateFromPath.js +3 -3
- package/lib/module/getStateFromPath.js.map +1 -1
- package/lib/module/index.js +28 -25
- 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/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 +28 -25
- package/lib/module/useDescriptors.js.map +1 -1
- package/lib/module/useEventEmitter.js +1 -1
- package/lib/module/useEventEmitter.js.map +1 -1
- package/lib/module/useFocusEffect.js +2 -2
- package/lib/module/useFocusEffect.js.map +1 -1
- package/lib/module/useFocusEvents.js +2 -2
- package/lib/module/useFocusEvents.js.map +1 -1
- package/lib/module/useFocusedListenersChildrenAdapter.js +2 -2
- 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/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 +24 -24
- package/lib/module/useNavigationBuilder.js.map +1 -1
- package/lib/module/useNavigationCache.js +11 -9
- 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 +3 -3
- package/lib/module/useNavigationHelpers.js.map +1 -1
- package/lib/module/useNavigationIndependentTree.js +6 -0
- package/lib/module/useNavigationIndependentTree.js.map +1 -0
- package/lib/module/useNavigationState.js +2 -2
- package/lib/module/useNavigationState.js.map +1 -1
- package/lib/module/useOnAction.js +14 -10
- package/lib/module/useOnAction.js.map +1 -1
- package/lib/module/useOnGetState.js +4 -4
- package/lib/module/useOnGetState.js.map +1 -1
- package/lib/module/useOnPreventRemove.js +3 -3
- 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 +3 -3
- package/lib/module/useOptionsGetters.js.map +1 -1
- package/lib/module/usePreventRemove.js +4 -4
- 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 +1 -1
- package/lib/module/useRouteCache.js.map +1 -1
- package/lib/module/useScheduleUpdate.js +1 -1
- package/lib/module/useScheduleUpdate.js.map +1 -1
- package/lib/module/useSyncState.js +1 -1
- package/lib/module/useSyncState.js.map +1 -1
- package/lib/module/validatePathConfig.js +1 -1
- package/lib/module/validatePathConfig.js.map +1 -1
- package/lib/typescript/src/BaseNavigationContainer.d.ts +3 -2
- 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 +6 -0
- package/lib/typescript/src/DeprecatedNavigationInChildContext.d.ts.map +1 -0
- package/lib/typescript/src/EnsureSingleNavigator.d.ts +2 -2
- 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 +10 -11
- 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 -2
- 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 +8 -0
- package/lib/typescript/src/NavigationIndependentTree.d.ts.map +1 -0
- package/lib/typescript/src/NavigationIndependentTreeContext.d.ts +6 -0
- package/lib/typescript/src/NavigationIndependentTreeContext.d.ts.map +1 -0
- 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 +1 -2
- package/lib/typescript/src/NavigationStateContext.d.ts.map +1 -1
- package/lib/typescript/src/PreventRemoveContext.d.ts +2 -3
- package/lib/typescript/src/PreventRemoveContext.d.ts.map +1 -1
- package/lib/typescript/src/PreventRemoveProvider.d.ts +2 -2
- 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 +159 -0
- package/lib/typescript/src/StaticNavigation.d.ts.map +1 -0
- 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 +8 -2
- package/lib/typescript/src/createNavigatorFactory.d.ts.map +1 -1
- package/lib/typescript/src/findFocusedRoute.d.ts +1 -1
- package/lib/typescript/src/findFocusedRoute.d.ts.map +1 -1
- package/lib/typescript/src/fromEntries.d.ts +1 -1
- package/lib/typescript/src/fromEntries.d.ts.map +1 -1
- package/lib/typescript/src/getActionFromState.d.ts +3 -3
- 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 +3 -3
- package/lib/typescript/src/getPathFromState.d.ts.map +1 -1
- package/lib/typescript/src/getStateFromPath.d.ts +3 -3
- package/lib/typescript/src/getStateFromPath.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +28 -25
- 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/types.d.ts +109 -48
- 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 +2 -2
- package/lib/typescript/src/useCurrentRender.d.ts.map +1 -1
- package/lib/typescript/src/useDescriptors.d.ts +12 -10
- package/lib/typescript/src/useDescriptors.d.ts.map +1 -1
- package/lib/typescript/src/useEventEmitter.d.ts +2 -2
- package/lib/typescript/src/useEventEmitter.d.ts.map +1 -1
- package/lib/typescript/src/useFocusEffect.d.ts +2 -2
- package/lib/typescript/src/useFocusEffect.d.ts.map +1 -1
- package/lib/typescript/src/useFocusEvents.d.ts +2 -2
- 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/useKeyedChildListeners.d.ts +1 -1
- package/lib/typescript/src/useKeyedChildListeners.d.ts.map +1 -1
- package/lib/typescript/src/useNavigation.d.ts +1 -1
- package/lib/typescript/src/useNavigation.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationBuilder.d.ts +20 -16
- package/lib/typescript/src/useNavigationBuilder.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationCache.d.ts +4 -4
- 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 +28 -10
- package/lib/typescript/src/useNavigationHelpers.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationIndependentTree.d.ts +2 -0
- package/lib/typescript/src/useNavigationIndependentTree.d.ts.map +1 -0
- package/lib/typescript/src/useNavigationState.d.ts +2 -2
- 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 +2 -2
- package/lib/typescript/src/useOnRouteFocus.d.ts.map +1 -1
- package/lib/typescript/src/useOptionsGetters.d.ts +2 -2
- 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/useScheduleUpdate.d.ts +1 -1
- package/lib/typescript/src/useScheduleUpdate.d.ts.map +1 -1
- package/lib/typescript/src/useSyncState.d.ts +1 -1
- 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/package.json +11 -11
- package/src/BaseNavigationContainer.tsx +82 -80
- package/src/CurrentRenderContext.tsx +1 -3
- package/src/DeprecatedNavigationInChildContext.tsx +6 -0
- package/src/EnsureSingleNavigator.tsx +1 -1
- package/src/Group.tsx +1 -1
- 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 +25 -0
- package/src/NavigationIndependentTreeContext.tsx +6 -0
- package/src/NavigationRouteContext.tsx +3 -5
- package/src/NavigationStateContext.tsx +1 -1
- package/src/PreventRemoveContext.tsx +1 -3
- package/src/PreventRemoveProvider.tsx +4 -4
- package/src/SceneView.tsx +5 -5
- package/src/Screen.tsx +1 -1
- package/src/StaticContainer.tsx +19 -18
- package/src/StaticNavigation.tsx +401 -0
- package/src/UnhandledActionContext.tsx +1 -3
- package/src/checkDuplicateRouteNames.tsx +1 -1
- package/src/checkSerializable.tsx +1 -1
- package/src/createNavigationContainerRef.tsx +1 -1
- package/src/createNavigatorFactory.tsx +41 -12
- package/src/findFocusedRoute.tsx +1 -1
- package/src/fromEntries.tsx +1 -3
- package/src/getActionFromState.tsx +3 -9
- package/src/getFocusedRouteNameFromRoute.tsx +1 -1
- package/src/getPathFromState.tsx +4 -4
- package/src/getStateFromPath.tsx +3 -3
- package/src/index.tsx +34 -25
- package/src/isArrayEqual.tsx +1 -1
- package/src/isRecordEqual.tsx +1 -4
- package/src/types.tsx +111 -29
- package/src/useChildListeners.tsx +1 -1
- package/src/useComponent.tsx +1 -1
- package/src/useCurrentRender.tsx +2 -6
- package/src/useDescriptors.tsx +32 -26
- package/src/useEventEmitter.tsx +1 -1
- package/src/useFocusEffect.tsx +2 -2
- package/src/useFocusEvents.tsx +2 -2
- package/src/useFocusedListenersChildrenAdapter.tsx +3 -2
- package/src/useIsFocused.tsx +2 -2
- package/src/useKeyedChildListeners.tsx +1 -1
- package/src/useNavigation.tsx +3 -3
- package/src/useNavigationBuilder.tsx +33 -28
- package/src/useNavigationCache.tsx +10 -6
- package/src/useNavigationContainerRef.tsx +2 -2
- package/src/useNavigationHelpers.tsx +3 -3
- package/src/useNavigationIndependentTree.tsx +7 -0
- package/src/useNavigationState.tsx +2 -2
- package/src/useOnAction.tsx +17 -8
- package/src/useOnGetState.tsx +5 -7
- package/src/useOnPreventRemove.tsx +4 -3
- package/src/useOnRouteFocus.tsx +2 -2
- package/src/useOptionsGetters.tsx +3 -7
- 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 +1 -1
- package/src/useScheduleUpdate.tsx +1 -1
- package/src/useSyncState.tsx +1 -1
- package/src/validatePathConfig.tsx +1 -1
package/src/index.tsx
CHANGED
|
@@ -1,27 +1,36 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
1
|
+
export { BaseNavigationContainer } from './BaseNavigationContainer';
|
|
2
|
+
export { createNavigationContainerRef } from './createNavigationContainerRef';
|
|
3
|
+
export { createNavigatorFactory } from './createNavigatorFactory';
|
|
4
|
+
export { CurrentRenderContext } from './CurrentRenderContext';
|
|
5
|
+
export { findFocusedRoute } from './findFocusedRoute';
|
|
6
|
+
export { getActionFromState } from './getActionFromState';
|
|
7
|
+
export { getFocusedRouteNameFromRoute } from './getFocusedRouteNameFromRoute';
|
|
8
|
+
export { getPathFromState } from './getPathFromState';
|
|
9
|
+
export { getStateFromPath } from './getStateFromPath';
|
|
10
|
+
export { NavigationContainerRefContext } from './NavigationContainerRefContext';
|
|
11
|
+
export { NavigationContext } from './NavigationContext';
|
|
12
|
+
export { NavigationHelpersContext } from './NavigationHelpersContext';
|
|
13
|
+
export { NavigationIndependentTree } from './NavigationIndependentTree';
|
|
14
|
+
export { NavigationRouteContext } from './NavigationRouteContext';
|
|
15
|
+
export { PreventRemoveContext } from './PreventRemoveContext';
|
|
16
|
+
export { PreventRemoveProvider } from './PreventRemoveProvider';
|
|
17
|
+
export {
|
|
18
|
+
type StaticNavigation,
|
|
19
|
+
type StaticParamList,
|
|
20
|
+
type StaticScreenProps,
|
|
21
|
+
createComponentForStaticNavigation,
|
|
22
|
+
createPathConfigForStaticNavigation,
|
|
23
|
+
} from './StaticNavigation';
|
|
16
24
|
export * from './types';
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
21
|
-
export {
|
|
22
|
-
export {
|
|
23
|
-
export {
|
|
24
|
-
export {
|
|
25
|
-
export {
|
|
26
|
-
export {
|
|
25
|
+
export { useFocusEffect } from './useFocusEffect';
|
|
26
|
+
export { useIsFocused } from './useIsFocused';
|
|
27
|
+
export { useNavigation } from './useNavigation';
|
|
28
|
+
export { useNavigationBuilder } from './useNavigationBuilder';
|
|
29
|
+
export { useNavigationContainerRef } from './useNavigationContainerRef';
|
|
30
|
+
export { useNavigationIndependentTree } from './useNavigationIndependentTree';
|
|
31
|
+
export { useNavigationState } from './useNavigationState';
|
|
32
|
+
export { UNSTABLE_usePreventRemove } from './usePreventRemove';
|
|
33
|
+
export { usePreventRemoveContext } from './usePreventRemoveContext';
|
|
34
|
+
export { useRoute } from './useRoute';
|
|
35
|
+
export { validatePathConfig } from './validatePathConfig';
|
|
27
36
|
export * from '@react-navigation/routers';
|
package/src/isArrayEqual.tsx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Compare two arrays with primitive values as the content.
|
|
3
3
|
* We need to make sure that both values and order match.
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
5
|
+
export function isArrayEqual(a: any[], b: any[]) {
|
|
6
6
|
if (a === b) {
|
|
7
7
|
return true;
|
|
8
8
|
}
|
package/src/isRecordEqual.tsx
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Compare two records with primitive values as the content.
|
|
3
3
|
*/
|
|
4
|
-
export
|
|
5
|
-
a: Record<string, any>,
|
|
6
|
-
b: Record<string, any>
|
|
7
|
-
) {
|
|
4
|
+
export function isRecordEqual(a: Record<string, any>, b: Record<string, any>) {
|
|
8
5
|
if (a === b) {
|
|
9
6
|
return true;
|
|
10
7
|
}
|
package/src/types.tsx
CHANGED
|
@@ -171,7 +171,7 @@ type NavigationHelpersCommon<
|
|
|
171
171
|
* @param action Action object or update function.
|
|
172
172
|
*/
|
|
173
173
|
dispatch(
|
|
174
|
-
action: NavigationAction | ((state: State) => NavigationAction)
|
|
174
|
+
action: NavigationAction | ((state: Readonly<State>) => NavigationAction)
|
|
175
175
|
): void;
|
|
176
176
|
|
|
177
177
|
/**
|
|
@@ -181,7 +181,7 @@ type NavigationHelpersCommon<
|
|
|
181
181
|
* @param [params] Params object for the route.
|
|
182
182
|
*/
|
|
183
183
|
navigate<RouteName extends keyof ParamList>(
|
|
184
|
-
...args: //
|
|
184
|
+
...args: // This condition allows us to iterate over a union type
|
|
185
185
|
// This is to avoid getting a union of all the params from `ParamList[RouteName]`,
|
|
186
186
|
// which will get our types all mixed up if a union RouteName is passed in.
|
|
187
187
|
RouteName extends unknown
|
|
@@ -198,18 +198,56 @@ type NavigationHelpersCommon<
|
|
|
198
198
|
/**
|
|
199
199
|
* Navigate to a route in current navigation tree.
|
|
200
200
|
*
|
|
201
|
-
* @param route Object with `
|
|
201
|
+
* @param route Object with `name` for the route to navigate to, and a `params` object.
|
|
202
202
|
*/
|
|
203
203
|
navigate<RouteName extends keyof ParamList>(
|
|
204
204
|
options: RouteName extends unknown
|
|
205
|
-
?
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
205
|
+
? {
|
|
206
|
+
name: RouteName;
|
|
207
|
+
params: ParamList[RouteName];
|
|
208
|
+
path?: string;
|
|
209
|
+
merge?: boolean;
|
|
210
|
+
}
|
|
211
|
+
: never
|
|
212
|
+
): void;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Navigate to a route in current navigation tree.
|
|
216
|
+
*
|
|
217
|
+
* @deprecated Use `navigate` instead.
|
|
218
|
+
*
|
|
219
|
+
* @param name Route name of the route.
|
|
220
|
+
* @param [params] Params object for the route.
|
|
221
|
+
*/
|
|
222
|
+
navigateDeprecated<RouteName extends keyof ParamList>(
|
|
223
|
+
...args: // This condition allows us to iterate over a union type
|
|
224
|
+
// This is to avoid getting a union of all the params from `ParamList[RouteName]`,
|
|
225
|
+
// which will get our types all mixed up if a union RouteName is passed in.
|
|
226
|
+
RouteName extends unknown
|
|
227
|
+
? // This condition checks if the params are optional,
|
|
228
|
+
// which means it's either undefined or a union with undefined
|
|
229
|
+
undefined extends ParamList[RouteName]
|
|
230
|
+
?
|
|
231
|
+
| [screen: RouteName] // if the params are optional, we don't have to provide it
|
|
232
|
+
| [screen: RouteName, params: ParamList[RouteName]]
|
|
233
|
+
: [screen: RouteName, params: ParamList[RouteName]]
|
|
234
|
+
: never
|
|
235
|
+
): void;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Navigate to a route in current navigation tree.
|
|
239
|
+
*
|
|
240
|
+
* @deprecated Use `navigate` instead.
|
|
241
|
+
*
|
|
242
|
+
* @param route Object with `name` for the route to navigate to, and a `params` object.
|
|
243
|
+
*/
|
|
244
|
+
navigateDeprecated<RouteName extends keyof ParamList>(
|
|
245
|
+
options: RouteName extends unknown
|
|
246
|
+
? {
|
|
247
|
+
name: RouteName;
|
|
248
|
+
params: ParamList[RouteName];
|
|
249
|
+
merge?: boolean;
|
|
250
|
+
}
|
|
213
251
|
: never
|
|
214
252
|
): void;
|
|
215
253
|
|
|
@@ -285,17 +323,25 @@ export type NavigationContainerProps = {
|
|
|
285
323
|
/**
|
|
286
324
|
* Callback which is called with the latest navigation state when it changes.
|
|
287
325
|
*/
|
|
288
|
-
onStateChange?: (state: NavigationState | undefined) => void;
|
|
326
|
+
onStateChange?: (state: Readonly<NavigationState> | undefined) => void;
|
|
327
|
+
/**
|
|
328
|
+
* Callback which is called after the navigation tree mounts.
|
|
329
|
+
*/
|
|
330
|
+
onReady?: () => void;
|
|
289
331
|
/**
|
|
290
332
|
* Callback which is called when an action is not handled.
|
|
291
333
|
*/
|
|
292
|
-
onUnhandledAction?: (action: NavigationAction) => void;
|
|
334
|
+
onUnhandledAction?: (action: Readonly<NavigationAction>) => void;
|
|
293
335
|
/**
|
|
294
|
-
* Whether
|
|
295
|
-
*
|
|
296
|
-
*
|
|
336
|
+
* Whether child navigator should handle a navigation action.
|
|
337
|
+
* The child navigator needs to be mounted before it can handle the action.
|
|
338
|
+
* Defaults to `false`.
|
|
339
|
+
*
|
|
340
|
+
* This will be removed in the next major release.
|
|
341
|
+
*
|
|
342
|
+
* @deprecated Use nested navigation API instead
|
|
297
343
|
*/
|
|
298
|
-
|
|
344
|
+
navigationInChildEnabled?: boolean;
|
|
299
345
|
/**
|
|
300
346
|
* Children elements to render.
|
|
301
347
|
*/
|
|
@@ -335,7 +381,7 @@ export type NavigationProp<
|
|
|
335
381
|
* Update the options for the route.
|
|
336
382
|
* The options object will be shallow merged with default options object.
|
|
337
383
|
*
|
|
338
|
-
* @param
|
|
384
|
+
* @param update Options object or a callback which takes the options from navigator config and returns a new options object.
|
|
339
385
|
*/
|
|
340
386
|
setOptions(options: Partial<ScreenOptions>): void;
|
|
341
387
|
} & EventConsumer<EventMap & EventMapCore<State>> &
|
|
@@ -372,11 +418,9 @@ export type CompositeNavigationProp<
|
|
|
372
418
|
*/
|
|
373
419
|
A extends NavigationProp<any, any, any, infer S> ? S : NavigationState,
|
|
374
420
|
/**
|
|
375
|
-
* Screen options
|
|
376
|
-
* This allows typechecking `setOptions`
|
|
421
|
+
* Screen options should refer to the options specified in the first type
|
|
377
422
|
*/
|
|
378
|
-
|
|
379
|
-
(B extends NavigationProp<any, any, any, any, infer P> ? P : {}),
|
|
423
|
+
A extends NavigationProp<any, any, any, any, infer O> ? O : {},
|
|
380
424
|
/**
|
|
381
425
|
* Event consumer config should refer to the config specified in the first type
|
|
382
426
|
* This allows typechecking `addListener`/`removeListener`
|
|
@@ -527,7 +571,11 @@ export type RouteConfig<
|
|
|
527
571
|
* For a given screen name, there will always be only one screen corresponding to an ID.
|
|
528
572
|
* If `undefined` is returned, it acts same as no `getId` being specified.
|
|
529
573
|
*/
|
|
530
|
-
getId?: ({
|
|
574
|
+
getId?: ({
|
|
575
|
+
params,
|
|
576
|
+
}: {
|
|
577
|
+
params: Readonly<ParamList[RouteName]>;
|
|
578
|
+
}) => string | undefined;
|
|
531
579
|
|
|
532
580
|
/**
|
|
533
581
|
* Initial params object for the route.
|
|
@@ -661,16 +709,13 @@ export type TypedNavigator<
|
|
|
661
709
|
) => null;
|
|
662
710
|
};
|
|
663
711
|
|
|
664
|
-
export type NavigatorScreenParams<
|
|
665
|
-
ParamList,
|
|
666
|
-
State extends NavigationState = NavigationState
|
|
667
|
-
> =
|
|
712
|
+
export type NavigatorScreenParams<ParamList extends {}> =
|
|
668
713
|
| {
|
|
669
714
|
screen?: never;
|
|
670
715
|
params?: never;
|
|
671
716
|
initial?: never;
|
|
672
717
|
path?: string;
|
|
673
|
-
state: PartialState<
|
|
718
|
+
state: PartialState<NavigationState> | NavigationState | undefined;
|
|
674
719
|
}
|
|
675
720
|
| {
|
|
676
721
|
[RouteName in keyof ParamList]: undefined extends ParamList[RouteName]
|
|
@@ -691,18 +736,55 @@ export type NavigatorScreenParams<
|
|
|
691
736
|
}[keyof ParamList];
|
|
692
737
|
|
|
693
738
|
export type PathConfig<ParamList extends {}> = {
|
|
739
|
+
/**
|
|
740
|
+
* Path string to match against.
|
|
741
|
+
* e.g. `/users/:id` will match `/users/1` and extract `id` param as `1`.
|
|
742
|
+
*/
|
|
694
743
|
path?: string;
|
|
744
|
+
/**
|
|
745
|
+
* Whether the path should be consider parent paths or use the exact path.
|
|
746
|
+
* By default, paths are relating to the path config on the parent screen.
|
|
747
|
+
* If `exact` is set to `true`, the parent path configuration is not used.
|
|
748
|
+
*/
|
|
695
749
|
exact?: boolean;
|
|
750
|
+
/**
|
|
751
|
+
* An object mapping the param name to a function which parses the param value.
|
|
752
|
+
*
|
|
753
|
+
* @example
|
|
754
|
+
* ```js
|
|
755
|
+
* parse: {
|
|
756
|
+
* id: Number,
|
|
757
|
+
* date: (value) => new Date(value)
|
|
758
|
+
* }
|
|
759
|
+
* ```
|
|
760
|
+
*/
|
|
696
761
|
parse?: Record<string, (value: string) => any>;
|
|
762
|
+
/**
|
|
763
|
+
* An object mapping the param name to a function which converts the param value to a string.
|
|
764
|
+
* By default, all params are converted to strings using `String(value)`.
|
|
765
|
+
*
|
|
766
|
+
* @example
|
|
767
|
+
* ```js
|
|
768
|
+
* stringify: {
|
|
769
|
+
* date: (value) => value.toISOString()
|
|
770
|
+
* }
|
|
771
|
+
* ```
|
|
772
|
+
*/
|
|
697
773
|
stringify?: Record<string, (value: any) => string>;
|
|
774
|
+
/**
|
|
775
|
+
* Path configuration for child screens.
|
|
776
|
+
*/
|
|
698
777
|
screens?: PathConfigMap<ParamList>;
|
|
778
|
+
/**
|
|
779
|
+
* Name of the initial route to use for the navigator when the path matches.
|
|
780
|
+
*/
|
|
699
781
|
initialRouteName?: keyof ParamList;
|
|
700
782
|
};
|
|
701
783
|
|
|
702
784
|
export type PathConfigMap<ParamList extends {}> = {
|
|
703
785
|
[RouteName in keyof ParamList]?: NonNullable<
|
|
704
786
|
ParamList[RouteName]
|
|
705
|
-
> extends NavigatorScreenParams<infer T
|
|
787
|
+
> extends NavigatorScreenParams<infer T>
|
|
706
788
|
? string | PathConfig<T>
|
|
707
789
|
: string | Omit<PathConfig<{}>, 'screens' | 'initialRouteName'>;
|
|
708
790
|
};
|
|
@@ -5,7 +5,7 @@ import type { ListenerMap } from './NavigationBuilderContext';
|
|
|
5
5
|
/**
|
|
6
6
|
* Hook which lets child navigators add action listeners.
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export function useChildListeners() {
|
|
9
9
|
const { current: listeners } = React.useRef<{
|
|
10
10
|
[K in keyof ListenerMap]: ListenerMap[K][];
|
|
11
11
|
}>({
|
package/src/useComponent.tsx
CHANGED
|
@@ -11,7 +11,7 @@ const NavigationContent = ({ render, children }: Props) => {
|
|
|
11
11
|
return render(children);
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
export
|
|
14
|
+
export function useComponent(render: Render) {
|
|
15
15
|
const renderRef = React.useRef<Render | null>(render);
|
|
16
16
|
|
|
17
17
|
// Normally refs shouldn't be mutated in render
|
package/src/useCurrentRender.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { NavigationState, ParamListBase } from '@react-navigation/routers';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
|
|
4
|
-
import CurrentRenderContext from './CurrentRenderContext';
|
|
4
|
+
import { CurrentRenderContext } from './CurrentRenderContext';
|
|
5
5
|
import type {
|
|
6
6
|
Descriptor,
|
|
7
7
|
NavigationHelpers,
|
|
@@ -22,11 +22,7 @@ type Options = {
|
|
|
22
22
|
* Write the current options, so that server renderer can get current values
|
|
23
23
|
* Mutating values like this is not safe in async mode, but it doesn't apply to SSR
|
|
24
24
|
*/
|
|
25
|
-
export
|
|
26
|
-
state,
|
|
27
|
-
navigation,
|
|
28
|
-
descriptors,
|
|
29
|
-
}: Options) {
|
|
25
|
+
export function useCurrentRender({ state, navigation, descriptors }: Options) {
|
|
30
26
|
const current = React.useContext(CurrentRenderContext);
|
|
31
27
|
|
|
32
28
|
if (current && navigation.isFocused()) {
|
package/src/useDescriptors.tsx
CHANGED
|
@@ -6,13 +6,14 @@ import type {
|
|
|
6
6
|
} from '@react-navigation/routers';
|
|
7
7
|
import * as React from 'react';
|
|
8
8
|
|
|
9
|
-
import
|
|
9
|
+
import {
|
|
10
10
|
AddKeyedListener,
|
|
11
11
|
AddListener,
|
|
12
|
+
NavigationBuilderContext,
|
|
12
13
|
} from './NavigationBuilderContext';
|
|
13
|
-
import NavigationContext from './NavigationContext';
|
|
14
|
-
import NavigationRouteContext from './NavigationRouteContext';
|
|
15
|
-
import SceneView from './SceneView';
|
|
14
|
+
import { NavigationContext } from './NavigationContext';
|
|
15
|
+
import { NavigationRouteContext } from './NavigationRouteContext';
|
|
16
|
+
import { SceneView } from './SceneView';
|
|
16
17
|
import type {
|
|
17
18
|
Descriptor,
|
|
18
19
|
EventMapBase,
|
|
@@ -22,8 +23,8 @@ import type {
|
|
|
22
23
|
RouteProp,
|
|
23
24
|
} from './types';
|
|
24
25
|
import type { NavigationEventEmitter } from './useEventEmitter';
|
|
25
|
-
import useNavigationCache from './useNavigationCache';
|
|
26
|
-
import useRouteCache from './useRouteCache';
|
|
26
|
+
import { useNavigationCache } from './useNavigationCache';
|
|
27
|
+
import { useRouteCache } from './useRouteCache';
|
|
27
28
|
|
|
28
29
|
export type ScreenConfigWithParent<
|
|
29
30
|
State extends NavigationState,
|
|
@@ -79,7 +80,7 @@ type Options<
|
|
|
79
80
|
* - Options specified by the screen for the navigator
|
|
80
81
|
* - Navigation object intended for the route
|
|
81
82
|
*/
|
|
82
|
-
export
|
|
83
|
+
export function useDescriptors<
|
|
83
84
|
State extends NavigationState,
|
|
84
85
|
ActionHelpers extends Record<string, () => void>,
|
|
85
86
|
ScreenOptions extends {},
|
|
@@ -99,7 +100,9 @@ export default function useDescriptors<
|
|
|
99
100
|
router,
|
|
100
101
|
emitter,
|
|
101
102
|
}: Options<State, ScreenOptions, EventMap>) {
|
|
102
|
-
const [options, setOptions] = React.useState<Record<string,
|
|
103
|
+
const [options, setOptions] = React.useState<Record<string, ScreenOptions>>(
|
|
104
|
+
{}
|
|
105
|
+
);
|
|
103
106
|
const { onDispatchAction, onOptionsChange, stackRef } = React.useContext(
|
|
104
107
|
NavigationBuilderContext
|
|
105
108
|
);
|
|
@@ -177,6 +180,7 @@ export default function useDescriptors<
|
|
|
177
180
|
(acc, curr) =>
|
|
178
181
|
Object.assign(
|
|
179
182
|
acc,
|
|
183
|
+
// @ts-expect-error: we check for function but TS still complains
|
|
180
184
|
typeof curr !== 'function' ? curr : curr({ route, navigation })
|
|
181
185
|
),
|
|
182
186
|
{} as ScreenOptions
|
|
@@ -205,29 +209,31 @@ export default function useDescriptors<
|
|
|
205
209
|
return o;
|
|
206
210
|
});
|
|
207
211
|
|
|
212
|
+
const element = (
|
|
213
|
+
<NavigationBuilderContext.Provider key={route.key} value={context}>
|
|
214
|
+
<NavigationContext.Provider value={navigation}>
|
|
215
|
+
<NavigationRouteContext.Provider value={route}>
|
|
216
|
+
<SceneView
|
|
217
|
+
navigation={navigation}
|
|
218
|
+
route={route}
|
|
219
|
+
screen={screen}
|
|
220
|
+
routeState={state.routes[i].state}
|
|
221
|
+
getState={getState}
|
|
222
|
+
setState={setState}
|
|
223
|
+
options={mergedOptions}
|
|
224
|
+
clearOptions={clearOptions}
|
|
225
|
+
/>
|
|
226
|
+
</NavigationRouteContext.Provider>
|
|
227
|
+
</NavigationContext.Provider>
|
|
228
|
+
</NavigationBuilderContext.Provider>
|
|
229
|
+
);
|
|
230
|
+
|
|
208
231
|
acc[route.key] = {
|
|
209
232
|
route,
|
|
210
233
|
// @ts-expect-error: it's missing action helpers, fix later
|
|
211
234
|
navigation,
|
|
212
235
|
render() {
|
|
213
|
-
return
|
|
214
|
-
<NavigationBuilderContext.Provider key={route.key} value={context}>
|
|
215
|
-
<NavigationContext.Provider value={navigation}>
|
|
216
|
-
<NavigationRouteContext.Provider value={route}>
|
|
217
|
-
<SceneView
|
|
218
|
-
navigation={navigation}
|
|
219
|
-
route={route}
|
|
220
|
-
screen={screen}
|
|
221
|
-
routeState={state.routes[i].state}
|
|
222
|
-
getState={getState}
|
|
223
|
-
setState={setState}
|
|
224
|
-
options={mergedOptions}
|
|
225
|
-
clearOptions={clearOptions}
|
|
226
|
-
/>
|
|
227
|
-
</NavigationRouteContext.Provider>
|
|
228
|
-
</NavigationContext.Provider>
|
|
229
|
-
</NavigationBuilderContext.Provider>
|
|
230
|
-
);
|
|
236
|
+
return element;
|
|
231
237
|
},
|
|
232
238
|
options: mergedOptions as ScreenOptions,
|
|
233
239
|
};
|
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,7 +11,7 @@ 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
17
|
if (arguments[1] !== undefined) {
|
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
|
|
4
|
+
import {
|
|
5
5
|
FocusedNavigationCallback,
|
|
6
6
|
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,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
import NavigationContainerRefContext from './NavigationContainerRefContext';
|
|
4
|
-
import NavigationContext from './NavigationContext';
|
|
3
|
+
import { NavigationContainerRefContext } from './NavigationContainerRefContext';
|
|
4
|
+
import { NavigationContext } from './NavigationContext';
|
|
5
5
|
import type { NavigationProp } from './types';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -9,7 +9,7 @@ import type { NavigationProp } from './types';
|
|
|
9
9
|
*
|
|
10
10
|
* @returns Navigation prop of the parent screen.
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
12
|
+
export function useNavigation<
|
|
13
13
|
T = NavigationProp<ReactNavigation.RootParamList>
|
|
14
14
|
>(): T {
|
|
15
15
|
const root = React.useContext(NavigationContainerRefContext);
|