@react-navigation/core 7.0.0-alpha.1 → 7.0.0-alpha.11
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 +25 -30
- package/lib/commonjs/BaseNavigationContainer.js.map +1 -1
- package/lib/commonjs/CurrentRenderContext.js +3 -4
- package/lib/commonjs/CurrentRenderContext.js.map +1 -1
- package/lib/commonjs/DeprecatedNavigationInChildContext.js +3 -4
- package/lib/commonjs/DeprecatedNavigationInChildContext.js.map +1 -1
- package/lib/commonjs/EnsureSingleNavigator.js +3 -4
- package/lib/commonjs/EnsureSingleNavigator.js.map +1 -1
- package/lib/commonjs/Group.js.map +1 -1
- package/lib/commonjs/NavigationBuilderContext.js +3 -4
- package/lib/commonjs/NavigationBuilderContext.js.map +1 -1
- package/lib/commonjs/NavigationContainerRefContext.js +3 -4
- package/lib/commonjs/NavigationContainerRefContext.js.map +1 -1
- package/lib/commonjs/NavigationContext.js +3 -4
- package/lib/commonjs/NavigationContext.js.map +1 -1
- package/lib/commonjs/NavigationHelpersContext.js +3 -4
- package/lib/commonjs/NavigationHelpersContext.js.map +1 -1
- package/lib/commonjs/NavigationIndependentTree.js +2 -2
- package/lib/commonjs/NavigationIndependentTree.js.map +1 -1
- package/lib/commonjs/NavigationIndependentTreeContext.js +3 -4
- package/lib/commonjs/NavigationIndependentTreeContext.js.map +1 -1
- package/lib/commonjs/NavigationRouteContext.js +3 -4
- package/lib/commonjs/NavigationRouteContext.js.map +1 -1
- package/lib/commonjs/NavigationStateContext.js +3 -4
- package/lib/commonjs/NavigationStateContext.js.map +1 -1
- package/lib/commonjs/PreventRemoveContext.js +8 -4
- package/lib/commonjs/PreventRemoveContext.js.map +1 -1
- package/lib/commonjs/PreventRemoveProvider.js +8 -10
- package/lib/commonjs/PreventRemoveProvider.js.map +1 -1
- package/lib/commonjs/SceneView.js +2 -2
- package/lib/commonjs/SceneView.js.map +1 -1
- package/lib/commonjs/Screen.js.map +1 -1
- package/lib/commonjs/StaticContainer.js +3 -4
- package/lib/commonjs/StaticContainer.js.map +1 -1
- package/lib/commonjs/StaticNavigation.js +34 -7
- package/lib/commonjs/StaticNavigation.js.map +1 -1
- package/lib/commonjs/UnhandledActionContext.js +3 -4
- package/lib/commonjs/UnhandledActionContext.js.map +1 -1
- package/lib/commonjs/checkDuplicateRouteNames.js +1 -2
- package/lib/commonjs/checkDuplicateRouteNames.js.map +1 -1
- package/lib/commonjs/checkSerializable.js.map +1 -1
- package/lib/commonjs/createNavigationContainerRef.js +1 -2
- package/lib/commonjs/createNavigationContainerRef.js.map +1 -1
- package/lib/commonjs/createNavigatorFactory.js +0 -3
- package/lib/commonjs/createNavigatorFactory.js.map +1 -1
- package/lib/commonjs/findFocusedRoute.js +2 -4
- package/lib/commonjs/findFocusedRoute.js.map +1 -1
- package/lib/commonjs/getActionFromState.js +6 -8
- 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 +25 -22
- package/lib/commonjs/getPathFromState.js.map +1 -1
- package/lib/commonjs/getStateFromPath.js +63 -21
- package/lib/commonjs/getStateFromPath.js.map +1 -1
- package/lib/commonjs/index.js +27 -3
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/isArrayEqual.js.map +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.map +1 -1
- package/lib/commonjs/useChildListeners.js +2 -2
- package/lib/commonjs/useChildListeners.js.map +1 -1
- package/lib/commonjs/useComponent.js +2 -2
- package/lib/commonjs/useComponent.js.map +1 -1
- package/lib/commonjs/useCurrentRender.js +2 -2
- package/lib/commonjs/useCurrentRender.js.map +1 -1
- package/lib/commonjs/useDescriptors.js +83 -31
- package/lib/commonjs/useDescriptors.js.map +1 -1
- package/lib/commonjs/useEventEmitter.js +5 -6
- package/lib/commonjs/useEventEmitter.js.map +1 -1
- package/lib/commonjs/useFocusEffect.js +4 -2
- package/lib/commonjs/useFocusEffect.js.map +1 -1
- package/lib/commonjs/useFocusEvents.js +4 -4
- package/lib/commonjs/useFocusEvents.js.map +1 -1
- package/lib/commonjs/useFocusedListenersChildrenAdapter.js +3 -3
- package/lib/commonjs/useFocusedListenersChildrenAdapter.js.map +1 -1
- package/lib/commonjs/useIsFocused.js +5 -4
- 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 +2 -2
- package/lib/commonjs/useKeyedChildListeners.js.map +1 -1
- package/lib/commonjs/useNavigation.js +2 -2
- package/lib/commonjs/useNavigation.js.map +1 -1
- package/lib/commonjs/useNavigationBuilder.js +81 -68
- package/lib/commonjs/useNavigationBuilder.js.map +1 -1
- package/lib/commonjs/useNavigationCache.js +57 -16
- package/lib/commonjs/useNavigationCache.js.map +1 -1
- package/lib/commonjs/useNavigationContainerRef.js +2 -2
- package/lib/commonjs/useNavigationContainerRef.js.map +1 -1
- package/lib/commonjs/useNavigationHelpers.js +4 -5
- package/lib/commonjs/useNavigationHelpers.js.map +1 -1
- package/lib/commonjs/useNavigationIndependentTree.js +2 -2
- package/lib/commonjs/useNavigationIndependentTree.js.map +1 -1
- package/lib/commonjs/useNavigationState.js +2 -2
- package/lib/commonjs/useNavigationState.js.map +1 -1
- package/lib/commonjs/useOnAction.js +6 -4
- package/lib/commonjs/useOnAction.js.map +1 -1
- package/lib/commonjs/useOnGetState.js +4 -5
- 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 +2 -2
- package/lib/commonjs/useOnRouteFocus.js.map +1 -1
- package/lib/commonjs/useOptionsGetters.js +9 -10
- package/lib/commonjs/useOptionsGetters.js.map +1 -1
- package/lib/commonjs/usePreventRemove.js +5 -5
- package/lib/commonjs/usePreventRemove.js.map +1 -1
- package/lib/commonjs/usePreventRemoveContext.js +2 -2
- package/lib/commonjs/usePreventRemoveContext.js.map +1 -1
- package/lib/commonjs/useRegisterNavigator.js +2 -2
- package/lib/commonjs/useRegisterNavigator.js.map +1 -1
- package/lib/commonjs/useRoute.js +2 -2
- package/lib/commonjs/useRoute.js.map +1 -1
- package/lib/commonjs/useRouteCache.js +19 -16
- package/lib/commonjs/useRouteCache.js.map +1 -1
- package/lib/commonjs/useSyncState.js +27 -56
- package/lib/commonjs/useSyncState.js.map +1 -1
- package/lib/commonjs/validatePathConfig.js +37 -10
- package/lib/commonjs/validatePathConfig.js.map +1 -1
- package/lib/module/BaseNavigationContainer.js +22 -26
- package/lib/module/BaseNavigationContainer.js.map +1 -1
- package/lib/module/CurrentRenderContext.js.map +1 -1
- package/lib/module/DeprecatedNavigationInChildContext.js.map +1 -1
- package/lib/module/EnsureSingleNavigator.js.map +1 -1
- package/lib/module/Group.js.map +1 -1
- package/lib/module/NavigationBuilderContext.js.map +1 -1
- package/lib/module/NavigationContainerRefContext.js.map +1 -1
- package/lib/module/NavigationContext.js.map +1 -1
- package/lib/module/NavigationHelpersContext.js.map +1 -1
- package/lib/module/NavigationIndependentTree.js.map +1 -1
- package/lib/module/NavigationIndependentTreeContext.js.map +1 -1
- package/lib/module/NavigationRouteContext.js.map +1 -1
- package/lib/module/NavigationStateContext.js.map +1 -1
- package/lib/module/PreventRemoveContext.js.map +1 -1
- package/lib/module/PreventRemoveProvider.js +6 -8
- package/lib/module/PreventRemoveProvider.js.map +1 -1
- package/lib/module/SceneView.js.map +1 -1
- package/lib/module/Screen.js.map +1 -1
- package/lib/module/StaticContainer.js.map +1 -1
- package/lib/module/StaticNavigation.js +27 -5
- package/lib/module/StaticNavigation.js.map +1 -1
- package/lib/module/UnhandledActionContext.js.map +1 -1
- package/lib/module/checkDuplicateRouteNames.js +1 -2
- package/lib/module/checkDuplicateRouteNames.js.map +1 -1
- package/lib/module/checkSerializable.js.map +1 -1
- package/lib/module/createNavigationContainerRef.js.map +1 -1
- package/lib/module/createNavigatorFactory.js +0 -3
- package/lib/module/createNavigatorFactory.js.map +1 -1
- package/lib/module/findFocusedRoute.js +2 -4
- package/lib/module/findFocusedRoute.js.map +1 -1
- package/lib/module/getActionFromState.js +6 -8
- 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 +23 -20
- package/lib/module/getPathFromState.js.map +1 -1
- package/lib/module/getStateFromPath.js +61 -19
- package/lib/module/getStateFromPath.js.map +1 -1
- package/lib/module/index.js +4 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/isArrayEqual.js.map +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.map +1 -1
- package/lib/module/useChildListeners.js.map +1 -1
- package/lib/module/useComponent.js.map +1 -1
- package/lib/module/useCurrentRender.js.map +1 -1
- package/lib/module/useDescriptors.js +81 -29
- package/lib/module/useDescriptors.js.map +1 -1
- package/lib/module/useEventEmitter.js +3 -4
- package/lib/module/useEventEmitter.js.map +1 -1
- package/lib/module/useFocusEffect.js +2 -0
- 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 +1 -1
- package/lib/module/useFocusedListenersChildrenAdapter.js.map +1 -1
- 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.map +1 -1
- package/lib/module/useNavigation.js.map +1 -1
- package/lib/module/useNavigationBuilder.js +78 -66
- package/lib/module/useNavigationBuilder.js.map +1 -1
- package/lib/module/useNavigationCache.js +55 -14
- package/lib/module/useNavigationCache.js.map +1 -1
- package/lib/module/useNavigationContainerRef.js.map +1 -1
- package/lib/module/useNavigationHelpers.js +2 -3
- package/lib/module/useNavigationHelpers.js.map +1 -1
- package/lib/module/useNavigationIndependentTree.js.map +1 -1
- package/lib/module/useNavigationState.js.map +1 -1
- package/lib/module/useOnAction.js +4 -2
- package/lib/module/useOnAction.js.map +1 -1
- package/lib/module/useOnGetState.js +2 -3
- package/lib/module/useOnGetState.js.map +1 -1
- package/lib/module/useOnPreventRemove.js +3 -4
- package/lib/module/useOnPreventRemove.js.map +1 -1
- package/lib/module/useOnRouteFocus.js.map +1 -1
- package/lib/module/useOptionsGetters.js +7 -8
- package/lib/module/useOptionsGetters.js.map +1 -1
- package/lib/module/usePreventRemove.js +2 -2
- package/lib/module/usePreventRemove.js.map +1 -1
- package/lib/module/usePreventRemoveContext.js.map +1 -1
- package/lib/module/useRegisterNavigator.js.map +1 -1
- package/lib/module/useRoute.js.map +1 -1
- package/lib/module/useRouteCache.js +16 -12
- 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 +37 -10
- package/lib/module/validatePathConfig.js.map +1 -1
- package/lib/typescript/src/BaseNavigationContainer.d.ts +2 -1
- package/lib/typescript/src/BaseNavigationContainer.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/NavigationContext.d.ts +1 -17
- package/lib/typescript/src/NavigationContext.d.ts.map +1 -1
- package/lib/typescript/src/NavigationHelpersContext.d.ts +1 -1
- package/lib/typescript/src/NavigationHelpersContext.d.ts.map +1 -1
- package/lib/typescript/src/NavigationIndependentTree.d.ts +1 -1
- package/lib/typescript/src/NavigationIndependentTree.d.ts.map +1 -1
- package/lib/typescript/src/NavigationRouteContext.d.ts +1 -1
- package/lib/typescript/src/NavigationRouteContext.d.ts.map +1 -1
- package/lib/typescript/src/NavigationStateContext.d.ts +2 -18
- package/lib/typescript/src/NavigationStateContext.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/StaticNavigation.d.ts +12 -5
- package/lib/typescript/src/StaticNavigation.d.ts.map +1 -1
- package/lib/typescript/src/createNavigatorFactory.d.ts.map +1 -1
- package/lib/typescript/src/findFocusedRoute.d.ts +1 -9
- package/lib/typescript/src/findFocusedRoute.d.ts.map +1 -1
- package/lib/typescript/src/getPathFromState.d.ts +1 -0
- package/lib/typescript/src/getPathFromState.d.ts.map +1 -1
- package/lib/typescript/src/getStateFromPath.d.ts +1 -0
- package/lib/typescript/src/getStateFromPath.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +5 -2
- package/lib/typescript/src/index.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/useComponent.d.ts +1 -1
- package/lib/typescript/src/useComponent.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/useFocusEffect.d.ts.map +1 -1
- package/lib/typescript/src/useFocusedListenersChildrenAdapter.d.ts +1 -1
- package/lib/typescript/src/useFocusedListenersChildrenAdapter.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/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/useNavigationHelpers.d.ts +25 -55
- package/lib/typescript/src/useNavigationHelpers.d.ts.map +1 -1
- package/lib/typescript/src/useOnAction.d.ts +1 -1
- package/lib/typescript/src/useOnAction.d.ts.map +1 -1
- package/lib/typescript/src/useOnGetState.d.ts +1 -1
- package/lib/typescript/src/useOnGetState.d.ts.map +1 -1
- package/lib/typescript/src/useOnPreventRemove.d.ts +1 -1
- package/lib/typescript/src/useOnPreventRemove.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/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 +35 -36
- package/src/Group.tsx +1 -1
- package/src/PreventRemoveProvider.tsx +4 -1
- package/src/SceneView.tsx +1 -1
- package/src/Screen.tsx +1 -1
- package/src/StaticNavigation.tsx +34 -32
- package/src/checkDuplicateRouteNames.tsx +1 -1
- package/src/createNavigationContainerRef.tsx +1 -1
- package/src/createNavigatorFactory.tsx +2 -4
- package/src/getActionFromState.tsx +1 -1
- package/src/getFocusedRouteNameFromRoute.tsx +3 -3
- package/src/getPathFromState.tsx +20 -12
- package/src/getStateFromPath.tsx +80 -19
- package/src/index.tsx +6 -3
- 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/useDescriptors.tsx +153 -59
- package/src/useFocusEffect.tsx +1 -0
- package/src/useFocusedListenersChildrenAdapter.tsx +2 -2
- package/src/useIsomorphicLayoutEffect.native.tsx +3 -0
- package/src/useIsomorphicLayoutEffect.tsx +7 -0
- package/src/useNavigation.tsx +4 -1
- package/src/useNavigationBuilder.tsx +123 -100
- package/src/useNavigationCache.tsx +91 -30
- package/src/useNavigationContainerRef.tsx +1 -1
- package/src/useNavigationHelpers.tsx +6 -7
- package/src/useOnAction.tsx +8 -3
- package/src/useOnGetState.tsx +1 -1
- package/src/useOnPreventRemove.tsx +1 -1
- package/src/useOptionsGetters.tsx +2 -2
- package/src/usePreventRemove.tsx +1 -1
- package/src/useRouteCache.tsx +17 -16
- 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 -11
- package/src/useScheduleUpdate.tsx +0 -32
|
@@ -39,8 +39,8 @@ export function useOptionsGetters({ key, options, navigation }: Options) {
|
|
|
39
39
|
}, [navigation, options, optionsChangeListener]);
|
|
40
40
|
|
|
41
41
|
const getOptionsFromListener = React.useCallback(() => {
|
|
42
|
-
for (
|
|
43
|
-
if (optionsGettersFromChildRef.current
|
|
42
|
+
for (const key in optionsGettersFromChildRef.current) {
|
|
43
|
+
if (key in optionsGettersFromChildRef.current) {
|
|
44
44
|
const result = optionsGettersFromChildRef.current[key]?.();
|
|
45
45
|
|
|
46
46
|
// null means unfocused route
|
package/src/usePreventRemove.tsx
CHANGED
|
@@ -14,7 +14,7 @@ import { useRoute } from './useRoute';
|
|
|
14
14
|
* @param preventRemove Boolean indicating whether to prevent screen from being removed.
|
|
15
15
|
* @param callback Function which is executed when screen was prevented from being removed.
|
|
16
16
|
*/
|
|
17
|
-
export function
|
|
17
|
+
export function usePreventRemove(
|
|
18
18
|
preventRemove: boolean,
|
|
19
19
|
callback: (options: { data: { action: NavigationAction } }) => void
|
|
20
20
|
) {
|
package/src/useRouteCache.tsx
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
NavigationState,
|
|
3
|
-
ParamListBase,
|
|
4
|
-
Route,
|
|
5
|
-
} from '@react-navigation/routers';
|
|
1
|
+
import type { NavigationState, ParamListBase } from '@react-navigation/routers';
|
|
6
2
|
import * as React from 'react';
|
|
7
3
|
|
|
4
|
+
import { isRecordEqual } from './isRecordEqual';
|
|
8
5
|
import type { RouteProp } from './types';
|
|
9
6
|
|
|
10
|
-
type RouteCache = Map<
|
|
7
|
+
type RouteCache = Map<string, RouteProp<ParamListBase>>;
|
|
11
8
|
|
|
12
9
|
/**
|
|
13
10
|
* Utilites such as `getFocusedRouteNameFromRoute` need to access state.
|
|
@@ -32,21 +29,25 @@ export function useRouteCache<State extends NavigationState>(
|
|
|
32
29
|
}
|
|
33
30
|
|
|
34
31
|
cache.current = routes.reduce((acc, route) => {
|
|
35
|
-
const previous = cache.current.get(route);
|
|
32
|
+
const previous = cache.current.get(route.key);
|
|
33
|
+
const { state, ...routeWithoutState } = route;
|
|
36
34
|
|
|
37
|
-
|
|
35
|
+
let proxy;
|
|
36
|
+
|
|
37
|
+
if (previous && isRecordEqual(previous, routeWithoutState)) {
|
|
38
38
|
// If a cached route object already exists, reuse it
|
|
39
|
-
|
|
39
|
+
proxy = previous;
|
|
40
40
|
} else {
|
|
41
|
-
|
|
41
|
+
proxy = routeWithoutState;
|
|
42
|
+
}
|
|
42
43
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
Object.defineProperty(proxy, CHILD_STATE, {
|
|
45
|
+
enumerable: false,
|
|
46
|
+
configurable: true,
|
|
47
|
+
value: state,
|
|
48
|
+
});
|
|
47
49
|
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
+
acc.set(route.key, proxy);
|
|
50
51
|
|
|
51
52
|
return acc;
|
|
52
53
|
}, new Map() as RouteCache);
|
package/src/useSyncState.tsx
CHANGED
|
@@ -1,74 +1,46 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const createStore = <T,>(getInitialState: () => T) => {
|
|
4
|
+
const listeners: (() => void)[] = [];
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
* This is definitely not compatible with concurrent mode, but we don't have a solution for sync state yet.
|
|
7
|
-
*/
|
|
8
|
-
export function useSyncState<T>(initialState?: (() => T) | T) {
|
|
9
|
-
const stateRef = React.useRef<T>(UNINTIALIZED_STATE as any);
|
|
10
|
-
const isSchedulingRef = React.useRef(false);
|
|
11
|
-
const isMountedRef = React.useRef(true);
|
|
6
|
+
let state: T = getInitialState();
|
|
12
7
|
|
|
13
|
-
|
|
14
|
-
isMountedRef.current = true;
|
|
8
|
+
const getState = () => state;
|
|
15
9
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (stateRef.current === UNINTIALIZED_STATE) {
|
|
22
|
-
stateRef.current =
|
|
23
|
-
// @ts-expect-error: initialState is a function, but TypeScript doesn't think so
|
|
24
|
-
typeof initialState === 'function' ? initialState() : initialState;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const [trackingState, setTrackingState] = React.useState(stateRef.current);
|
|
28
|
-
|
|
29
|
-
const getState = React.useCallback(() => stateRef.current, []);
|
|
10
|
+
const setState = (newState: T) => {
|
|
11
|
+
state = newState;
|
|
12
|
+
listeners.forEach((listener) => listener());
|
|
13
|
+
};
|
|
30
14
|
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
15
|
+
const subscribe = (callback: () => void) => {
|
|
16
|
+
listeners.push(callback);
|
|
35
17
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (!isSchedulingRef.current) {
|
|
39
|
-
setTrackingState(state);
|
|
40
|
-
}
|
|
41
|
-
}, []);
|
|
42
|
-
|
|
43
|
-
const scheduleUpdate = React.useCallback((callback: () => void) => {
|
|
44
|
-
isSchedulingRef.current = true;
|
|
45
|
-
|
|
46
|
-
try {
|
|
47
|
-
callback();
|
|
48
|
-
} finally {
|
|
49
|
-
isSchedulingRef.current = false;
|
|
50
|
-
}
|
|
51
|
-
}, []);
|
|
18
|
+
return () => {
|
|
19
|
+
const index = listeners.indexOf(callback);
|
|
52
20
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
21
|
+
if (index > -1) {
|
|
22
|
+
listeners.splice(index, 1);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
};
|
|
57
26
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
27
|
+
return {
|
|
28
|
+
getState,
|
|
29
|
+
setState,
|
|
30
|
+
subscribe,
|
|
31
|
+
};
|
|
32
|
+
};
|
|
62
33
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (trackingState !== stateRef.current) {
|
|
66
|
-
setTrackingState(stateRef.current);
|
|
67
|
-
}
|
|
34
|
+
export function useSyncState<T>(getInitialState: () => T) {
|
|
35
|
+
const store = React.useRef(createStore(getInitialState)).current;
|
|
68
36
|
|
|
69
|
-
const state =
|
|
37
|
+
const state = React.useSyncExternalStore(
|
|
38
|
+
store.subscribe,
|
|
39
|
+
store.getState,
|
|
40
|
+
store.getState
|
|
41
|
+
);
|
|
70
42
|
|
|
71
43
|
React.useDebugValue(state);
|
|
72
44
|
|
|
73
|
-
return [state, getState, setState
|
|
45
|
+
return [state, store.getState, store.setState] as const;
|
|
74
46
|
}
|
|
@@ -1,28 +1,72 @@
|
|
|
1
|
-
const formatToList = (items: string
|
|
2
|
-
|
|
1
|
+
const formatToList = (items: Record<string, string>) =>
|
|
2
|
+
Object.entries(items)
|
|
3
|
+
.map(([key, value]) => `- ${key} (${value})`)
|
|
4
|
+
.join('\n');
|
|
3
5
|
|
|
4
|
-
export function validatePathConfig(config:
|
|
5
|
-
const
|
|
6
|
+
export function validatePathConfig(config: unknown, root = true) {
|
|
7
|
+
const validation = {
|
|
8
|
+
path: 'string',
|
|
9
|
+
initialRouteName: 'string',
|
|
10
|
+
screens: 'object',
|
|
11
|
+
...(root
|
|
12
|
+
? null
|
|
13
|
+
: {
|
|
14
|
+
exact: 'boolean',
|
|
15
|
+
stringify: 'object',
|
|
16
|
+
parse: 'object',
|
|
17
|
+
}),
|
|
18
|
+
};
|
|
6
19
|
|
|
7
|
-
if (
|
|
8
|
-
|
|
20
|
+
if (typeof config !== 'object' || config === null) {
|
|
21
|
+
throw new Error(
|
|
22
|
+
`Expected the configuration to be an object, but got ${JSON.stringify(
|
|
23
|
+
config
|
|
24
|
+
)}.`
|
|
25
|
+
);
|
|
9
26
|
}
|
|
10
27
|
|
|
11
|
-
const
|
|
12
|
-
|
|
28
|
+
const validationErrors = Object.fromEntries(
|
|
29
|
+
Object.keys(config)
|
|
30
|
+
.map((key) => {
|
|
31
|
+
if (key in validation) {
|
|
32
|
+
const type = validation[key as keyof typeof validation];
|
|
33
|
+
// @ts-expect-error: we know the key exists
|
|
34
|
+
const value = config[key];
|
|
35
|
+
|
|
36
|
+
if (typeof value !== type) {
|
|
37
|
+
return [key, `expected '${type}', got '${typeof value}'`];
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
return [key, 'extraneous'];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return null;
|
|
44
|
+
})
|
|
45
|
+
.filter(Boolean) as [string, string][]
|
|
13
46
|
);
|
|
14
47
|
|
|
15
|
-
if (
|
|
48
|
+
if (Object.keys(validationErrors).length) {
|
|
16
49
|
throw new Error(
|
|
17
50
|
`Found invalid properties in the configuration:\n${formatToList(
|
|
18
|
-
|
|
19
|
-
)}\n\
|
|
20
|
-
|
|
21
|
-
)}\n\nSee https://reactnavigation.org/docs/configuring-links for more details on how to specify a linking configuration.`
|
|
51
|
+
validationErrors
|
|
52
|
+
)}\n\nYou can only specify the following properties:\n${formatToList(
|
|
53
|
+
validation
|
|
54
|
+
)}\n\nIf you want to specify configuration for screens, you need to specify them under a 'screens' property.\n\nSee https://reactnavigation.org/docs/configuring-links for more details on how to specify a linking configuration.`
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (
|
|
59
|
+
root &&
|
|
60
|
+
'path' in config &&
|
|
61
|
+
typeof config.path === 'string' &&
|
|
62
|
+
config.path.includes(':')
|
|
63
|
+
) {
|
|
64
|
+
throw new Error(
|
|
65
|
+
`Found invalid path '${config.path}'. The 'path' in the top-level configuration cannot contain patterns for params.`
|
|
22
66
|
);
|
|
23
67
|
}
|
|
24
68
|
|
|
25
|
-
if (config.screens) {
|
|
69
|
+
if ('screens' in config && config.screens) {
|
|
26
70
|
Object.entries(config.screens).forEach(([_, value]) => {
|
|
27
71
|
if (typeof value !== 'string') {
|
|
28
72
|
validatePathConfig(value, false);
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.fromEntries = fromEntries;
|
|
7
|
-
// Object.fromEntries is not available in older iOS versions
|
|
8
|
-
function fromEntries(entries) {
|
|
9
|
-
return entries.reduce((acc, _ref) => {
|
|
10
|
-
let [k, v] = _ref;
|
|
11
|
-
if (acc.hasOwnProperty(k)) {
|
|
12
|
-
throw new Error(`A value for key '${k}' already exists in the object.`);
|
|
13
|
-
}
|
|
14
|
-
acc[k] = v;
|
|
15
|
-
return acc;
|
|
16
|
-
}, {});
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=fromEntries.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["fromEntries","entries","reduce","acc","k","v","hasOwnProperty","Error"],"sourceRoot":"../../src","sources":["fromEntries.tsx"],"mappings":";;;;;;AAAA;AACO,SAASA,WAAW,CAAsBC,OAA4B,EAAE;EAC7E,OAAOA,OAAO,CAACC,MAAM,CAAC,CAACC,GAAG,WAAa;IAAA,IAAX,CAACC,CAAC,EAAEC,CAAC,CAAC;IAChC,IAAIF,GAAG,CAACG,cAAc,CAACF,CAAC,CAAC,EAAE;MACzB,MAAM,IAAIG,KAAK,CAAE,oBAAmBH,CAAE,iCAAgC,CAAC;IACzE;IAEAD,GAAG,CAACC,CAAC,CAAC,GAAGC,CAAC;IACV,OAAOF,GAAG;EACZ,CAAC,EAAE,CAAC,CAAC,CAAiB;AACxB"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ScheduleUpdateContext = void 0;
|
|
7
|
-
exports.useScheduleUpdate = useScheduleUpdate;
|
|
8
|
-
var React = _interopRequireWildcard(require("react"));
|
|
9
|
-
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); }
|
|
10
|
-
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; }
|
|
11
|
-
const MISSING_CONTEXT_ERROR = "Couldn't find a schedule context.";
|
|
12
|
-
const ScheduleUpdateContext = /*#__PURE__*/React.createContext({
|
|
13
|
-
scheduleUpdate() {
|
|
14
|
-
throw new Error(MISSING_CONTEXT_ERROR);
|
|
15
|
-
},
|
|
16
|
-
flushUpdates() {
|
|
17
|
-
throw new Error(MISSING_CONTEXT_ERROR);
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* When screen config changes, we want to update the navigator in the same update phase.
|
|
23
|
-
* However, navigation state is in the root component and React won't let us update it from a child.
|
|
24
|
-
* This is a workaround for that, the scheduled update is stored in the ref without actually calling setState.
|
|
25
|
-
* It lets all subsequent updates access the latest state so it stays correct.
|
|
26
|
-
* Then we call setState during after the component updates.
|
|
27
|
-
*/
|
|
28
|
-
exports.ScheduleUpdateContext = ScheduleUpdateContext;
|
|
29
|
-
function useScheduleUpdate(callback) {
|
|
30
|
-
const {
|
|
31
|
-
scheduleUpdate,
|
|
32
|
-
flushUpdates
|
|
33
|
-
} = React.useContext(ScheduleUpdateContext);
|
|
34
|
-
scheduleUpdate(callback);
|
|
35
|
-
React.useEffect(flushUpdates);
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=useScheduleUpdate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["MISSING_CONTEXT_ERROR","ScheduleUpdateContext","React","createContext","scheduleUpdate","Error","flushUpdates","useScheduleUpdate","callback","useContext","useEffect"],"sourceRoot":"../../src","sources":["useScheduleUpdate.tsx"],"mappings":";;;;;;;AAAA;AAA+B;AAAA;AAE/B,MAAMA,qBAAqB,GAAG,mCAAmC;AAE1D,MAAMC,qBAAqB,gBAAGC,KAAK,CAACC,aAAa,CAGrD;EACDC,cAAc,GAAG;IACf,MAAM,IAAIC,KAAK,CAACL,qBAAqB,CAAC;EACxC,CAAC;EACDM,YAAY,GAAG;IACb,MAAM,IAAID,KAAK,CAACL,qBAAqB,CAAC;EACxC;AACF,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AANA;AAOO,SAASO,iBAAiB,CAACC,QAAoB,EAAE;EACtD,MAAM;IAAEJ,cAAc;IAAEE;EAAa,CAAC,GAAGJ,KAAK,CAACO,UAAU,CACvDR,qBAAqB,CACtB;EAEDG,cAAc,CAACI,QAAQ,CAAC;EAExBN,KAAK,CAACQ,SAAS,CAACJ,YAAY,CAAC;AAC/B"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// Object.fromEntries is not available in older iOS versions
|
|
2
|
-
export function fromEntries(entries) {
|
|
3
|
-
return entries.reduce((acc, _ref) => {
|
|
4
|
-
let [k, v] = _ref;
|
|
5
|
-
if (acc.hasOwnProperty(k)) {
|
|
6
|
-
throw new Error(`A value for key '${k}' already exists in the object.`);
|
|
7
|
-
}
|
|
8
|
-
acc[k] = v;
|
|
9
|
-
return acc;
|
|
10
|
-
}, {});
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=fromEntries.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["fromEntries","entries","reduce","acc","k","v","hasOwnProperty","Error"],"sourceRoot":"../../src","sources":["fromEntries.tsx"],"mappings":"AAAA;AACA,OAAO,SAASA,WAAW,CAAsBC,OAA4B,EAAE;EAC7E,OAAOA,OAAO,CAACC,MAAM,CAAC,CAACC,GAAG,WAAa;IAAA,IAAX,CAACC,CAAC,EAAEC,CAAC,CAAC;IAChC,IAAIF,GAAG,CAACG,cAAc,CAACF,CAAC,CAAC,EAAE;MACzB,MAAM,IAAIG,KAAK,CAAE,oBAAmBH,CAAE,iCAAgC,CAAC;IACzE;IAEAD,GAAG,CAACC,CAAC,CAAC,GAAGC,CAAC;IACV,OAAOF,GAAG;EACZ,CAAC,EAAE,CAAC,CAAC,CAAiB;AACxB"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
const MISSING_CONTEXT_ERROR = "Couldn't find a schedule context.";
|
|
3
|
-
export const ScheduleUpdateContext = /*#__PURE__*/React.createContext({
|
|
4
|
-
scheduleUpdate() {
|
|
5
|
-
throw new Error(MISSING_CONTEXT_ERROR);
|
|
6
|
-
},
|
|
7
|
-
flushUpdates() {
|
|
8
|
-
throw new Error(MISSING_CONTEXT_ERROR);
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* When screen config changes, we want to update the navigator in the same update phase.
|
|
14
|
-
* However, navigation state is in the root component and React won't let us update it from a child.
|
|
15
|
-
* This is a workaround for that, the scheduled update is stored in the ref without actually calling setState.
|
|
16
|
-
* It lets all subsequent updates access the latest state so it stays correct.
|
|
17
|
-
* Then we call setState during after the component updates.
|
|
18
|
-
*/
|
|
19
|
-
export function useScheduleUpdate(callback) {
|
|
20
|
-
const {
|
|
21
|
-
scheduleUpdate,
|
|
22
|
-
flushUpdates
|
|
23
|
-
} = React.useContext(ScheduleUpdateContext);
|
|
24
|
-
scheduleUpdate(callback);
|
|
25
|
-
React.useEffect(flushUpdates);
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=useScheduleUpdate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","MISSING_CONTEXT_ERROR","ScheduleUpdateContext","createContext","scheduleUpdate","Error","flushUpdates","useScheduleUpdate","callback","useContext","useEffect"],"sourceRoot":"../../src","sources":["useScheduleUpdate.tsx"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAE9B,MAAMC,qBAAqB,GAAG,mCAAmC;AAEjE,OAAO,MAAMC,qBAAqB,gBAAGF,KAAK,CAACG,aAAa,CAGrD;EACDC,cAAc,GAAG;IACf,MAAM,IAAIC,KAAK,CAACJ,qBAAqB,CAAC;EACxC,CAAC;EACDK,YAAY,GAAG;IACb,MAAM,IAAID,KAAK,CAACJ,qBAAqB,CAAC;EACxC;AACF,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASM,iBAAiB,CAACC,QAAoB,EAAE;EACtD,MAAM;IAAEJ,cAAc;IAAEE;EAAa,CAAC,GAAGN,KAAK,CAACS,UAAU,CACvDP,qBAAqB,CACtB;EAEDE,cAAc,CAACI,QAAQ,CAAC;EAExBR,KAAK,CAACU,SAAS,CAACJ,YAAY,CAAC;AAC/B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fromEntries.d.ts","sourceRoot":"","sources":["../../../src/fromEntries.tsx"],"names":[],"mappings":"AACA,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,gBAS5E"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
export declare const ScheduleUpdateContext: React.Context<{
|
|
3
|
-
scheduleUpdate: (callback: () => void) => void;
|
|
4
|
-
flushUpdates: () => void;
|
|
5
|
-
}>;
|
|
6
|
-
/**
|
|
7
|
-
* When screen config changes, we want to update the navigator in the same update phase.
|
|
8
|
-
* However, navigation state is in the root component and React won't let us update it from a child.
|
|
9
|
-
* This is a workaround for that, the scheduled update is stored in the ref without actually calling setState.
|
|
10
|
-
* It lets all subsequent updates access the latest state so it stays correct.
|
|
11
|
-
* Then we call setState during after the component updates.
|
|
12
|
-
*/
|
|
13
|
-
export declare function useScheduleUpdate(callback: () => void): void;
|
|
14
|
-
//# sourceMappingURL=useScheduleUpdate.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useScheduleUpdate.d.ts","sourceRoot":"","sources":["../../../src/useScheduleUpdate.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,eAAO,MAAM,qBAAqB;+BACL,MAAM,IAAI,KAAK,IAAI;kBAChC,MAAM,IAAI;EAQxB,CAAC;AAEH;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,IAAI,QAQrD"}
|
package/src/fromEntries.tsx
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// Object.fromEntries is not available in older iOS versions
|
|
2
|
-
export function fromEntries<K extends string, V>(entries: (readonly [K, V])[]) {
|
|
3
|
-
return entries.reduce((acc, [k, v]) => {
|
|
4
|
-
if (acc.hasOwnProperty(k)) {
|
|
5
|
-
throw new Error(`A value for key '${k}' already exists in the object.`);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
acc[k] = v;
|
|
9
|
-
return acc;
|
|
10
|
-
}, {} as Record<K, V>);
|
|
11
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
const MISSING_CONTEXT_ERROR = "Couldn't find a schedule context.";
|
|
4
|
-
|
|
5
|
-
export const ScheduleUpdateContext = React.createContext<{
|
|
6
|
-
scheduleUpdate: (callback: () => void) => void;
|
|
7
|
-
flushUpdates: () => void;
|
|
8
|
-
}>({
|
|
9
|
-
scheduleUpdate() {
|
|
10
|
-
throw new Error(MISSING_CONTEXT_ERROR);
|
|
11
|
-
},
|
|
12
|
-
flushUpdates() {
|
|
13
|
-
throw new Error(MISSING_CONTEXT_ERROR);
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* When screen config changes, we want to update the navigator in the same update phase.
|
|
19
|
-
* However, navigation state is in the root component and React won't let us update it from a child.
|
|
20
|
-
* This is a workaround for that, the scheduled update is stored in the ref without actually calling setState.
|
|
21
|
-
* It lets all subsequent updates access the latest state so it stays correct.
|
|
22
|
-
* Then we call setState during after the component updates.
|
|
23
|
-
*/
|
|
24
|
-
export function useScheduleUpdate(callback: () => void) {
|
|
25
|
-
const { scheduleUpdate, flushUpdates } = React.useContext(
|
|
26
|
-
ScheduleUpdateContext
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
scheduleUpdate(callback);
|
|
30
|
-
|
|
31
|
-
React.useEffect(flushUpdates);
|
|
32
|
-
}
|