@react-navigation/core 8.0.0-alpha.34 → 8.0.0-alpha.36
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 +17 -14
- package/lib/module/BaseNavigationContainer.js +14 -2
- package/lib/module/BaseNavigationContainer.js.map +1 -1
- package/lib/module/NavigationIndependentTree.js +9 -6
- package/lib/module/NavigationIndependentTree.js.map +1 -1
- package/lib/module/NavigationProvider.js +9 -4
- package/lib/module/NavigationProvider.js.map +1 -1
- package/lib/module/PreventRemoveProvider.js +2 -2
- package/lib/module/PreventRemoveProvider.js.map +1 -1
- package/lib/module/SceneView.js +2 -1
- package/lib/module/SceneView.js.map +1 -1
- package/lib/module/getPathFromState.js +11 -7
- package/lib/module/getPathFromState.js.map +1 -1
- package/lib/module/getStateFromPath.js +1 -1
- package/lib/module/getStateFromPath.js.map +1 -1
- package/lib/module/queryString.js +71 -0
- package/lib/module/queryString.js.map +1 -0
- package/lib/module/useDescriptors.js +7 -4
- package/lib/module/useDescriptors.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 -2
- package/lib/module/useFocusEvents.js.map +1 -1
- package/lib/module/useIsFocused.js +1 -0
- package/lib/module/useIsFocused.js.map +1 -1
- package/lib/module/useNavigationBuilder.js +40 -37
- package/lib/module/useNavigationBuilder.js.map +1 -1
- package/lib/module/useNavigationCache.js +82 -78
- package/lib/module/useNavigationCache.js.map +1 -1
- package/lib/module/useNavigationState.js +48 -23
- package/lib/module/useNavigationState.js.map +1 -1
- package/lib/module/useOptionsGetters.js +18 -17
- package/lib/module/useOptionsGetters.js.map +1 -1
- package/lib/module/usePreventRemoveContext.js +1 -1
- package/lib/module/usePreventRemoveContext.js.map +1 -1
- package/lib/module/useRouteCache.js +43 -33
- package/lib/module/useRouteCache.js.map +1 -1
- package/lib/module/useScheduleUpdate.js +3 -1
- package/lib/module/useScheduleUpdate.js.map +1 -1
- package/lib/module/useSyncState.js +9 -10
- package/lib/module/useSyncState.js.map +1 -1
- package/lib/typescript/src/BaseNavigationContainer.d.ts.map +1 -1
- package/lib/typescript/src/NavigationBuilderContext.d.ts +1 -1
- package/lib/typescript/src/NavigationBuilderContext.d.ts.map +1 -1
- package/lib/typescript/src/NavigationIndependentTree.d.ts.map +1 -1
- package/lib/typescript/src/NavigationProvider.d.ts.map +1 -1
- package/lib/typescript/src/PreventRemoveProvider.d.ts.map +1 -1
- package/lib/typescript/src/SceneView.d.ts +2 -1
- package/lib/typescript/src/SceneView.d.ts.map +1 -1
- package/lib/typescript/src/getPathFromState.d.ts.map +1 -1
- package/lib/typescript/src/queryString.d.ts +5 -0
- package/lib/typescript/src/queryString.d.ts.map +1 -0
- package/lib/typescript/src/useDescriptors.d.ts +2 -2
- package/lib/typescript/src/useDescriptors.d.ts.map +1 -1
- package/lib/typescript/src/useFocusEffect.d.ts.map +1 -1
- package/lib/typescript/src/useFocusEvents.d.ts.map +1 -1
- package/lib/typescript/src/useIsFocused.d.ts +1 -0
- package/lib/typescript/src/useIsFocused.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationBuilder.d.ts +1 -3
- package/lib/typescript/src/useNavigationBuilder.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationCache.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationState.d.ts +1 -0
- package/lib/typescript/src/useNavigationState.d.ts.map +1 -1
- package/lib/typescript/src/useOptionsGetters.d.ts +2 -4
- package/lib/typescript/src/useOptionsGetters.d.ts.map +1 -1
- package/lib/typescript/src/useRouteCache.d.ts +7 -12
- package/lib/typescript/src/useRouteCache.d.ts.map +1 -1
- package/lib/typescript/src/useScheduleUpdate.d.ts.map +1 -1
- package/lib/typescript/src/useSyncState.d.ts.map +1 -1
- package/package.json +2 -3
- package/src/BaseNavigationContainer.tsx +19 -2
- package/src/NavigationBuilderContext.tsx +1 -1
- package/src/NavigationIndependentTree.tsx +16 -8
- package/src/NavigationProvider.tsx +13 -4
- package/src/PreventRemoveProvider.tsx +2 -8
- package/src/SceneView.tsx +3 -1
- package/src/getPathFromState.tsx +7 -5
- package/src/getStateFromPath.tsx +1 -1
- package/src/queryString.ts +109 -0
- package/src/useDescriptors.tsx +18 -5
- package/src/useFocusEffect.tsx +5 -2
- package/src/useFocusEvents.tsx +5 -2
- package/src/useIsFocused.tsx +4 -0
- package/src/useNavigationBuilder.tsx +53 -45
- package/src/useNavigationCache.tsx +127 -105
- package/src/useNavigationState.tsx +60 -29
- package/src/useOptionsGetters.tsx +24 -24
- package/src/usePreventRemoveContext.tsx +1 -1
- package/src/useRouteCache.tsx +49 -33
- package/src/useScheduleUpdate.tsx +4 -1
- package/src/useSyncState.tsx +9 -11
- package/lib/module/useComponent.js +0 -34
- package/lib/module/useComponent.js.map +0 -1
- package/lib/typescript/src/useComponent.d.ts +0 -7
- package/lib/typescript/src/useComponent.d.ts.map +0 -1
- package/src/useComponent.tsx +0 -37
package/src/useSyncState.tsx
CHANGED
|
@@ -108,25 +108,23 @@ export function useSyncState<T>(getInitialState: () => T) {
|
|
|
108
108
|
return unsubscribe;
|
|
109
109
|
}, [store]);
|
|
110
110
|
|
|
111
|
-
const
|
|
111
|
+
const pendingUpdates = useLazyValue(() => new Set<() => void>());
|
|
112
112
|
|
|
113
113
|
const scheduleUpdate = useLatestCallback((callback: () => void) => {
|
|
114
|
-
|
|
114
|
+
pendingUpdates.add(callback);
|
|
115
115
|
});
|
|
116
116
|
|
|
117
117
|
const flushUpdates = useLatestCallback(() => {
|
|
118
|
-
|
|
118
|
+
if (pendingUpdates.size !== 0) {
|
|
119
|
+
// Updates are queued child-first as insertion effects run bottom-up.
|
|
120
|
+
// The root navigator replaces the whole state while nested navigators merge into it.
|
|
121
|
+
// So we apply them root-first to avoid the root clobbering nested updates.
|
|
122
|
+
const callbacks = Array.from(pendingUpdates).reverse();
|
|
119
123
|
|
|
120
|
-
|
|
124
|
+
pendingUpdates.clear();
|
|
121
125
|
|
|
122
|
-
if (pendingUpdates.length !== 0) {
|
|
123
126
|
store.batchUpdates(() => {
|
|
124
|
-
|
|
125
|
-
// The root navigator replaces the whole state while nested navigators merge into it.
|
|
126
|
-
// So we apply them root-first to avoid the root clobbering nested updates.
|
|
127
|
-
pendingUpdates.reverse();
|
|
128
|
-
|
|
129
|
-
for (const update of pendingUpdates) {
|
|
127
|
+
for (const update of callbacks) {
|
|
130
128
|
update();
|
|
131
129
|
}
|
|
132
130
|
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
const NavigationContent = ({
|
|
6
|
-
render,
|
|
7
|
-
children
|
|
8
|
-
}) => {
|
|
9
|
-
return render(children);
|
|
10
|
-
};
|
|
11
|
-
export function useComponent(render) {
|
|
12
|
-
const renderRef = React.useRef(render);
|
|
13
|
-
|
|
14
|
-
// Normally refs shouldn't be mutated in render
|
|
15
|
-
// But we return a component which will be rendered
|
|
16
|
-
// So it's just for immediate consumption
|
|
17
|
-
renderRef.current = render;
|
|
18
|
-
React.useEffect(() => {
|
|
19
|
-
renderRef.current = null;
|
|
20
|
-
});
|
|
21
|
-
return React.useRef(({
|
|
22
|
-
children
|
|
23
|
-
}) => {
|
|
24
|
-
const render = renderRef.current;
|
|
25
|
-
if (render === null) {
|
|
26
|
-
throw new Error('The returned component must be rendered in the same render phase as the hook.');
|
|
27
|
-
}
|
|
28
|
-
return /*#__PURE__*/_jsx(NavigationContent, {
|
|
29
|
-
render: render,
|
|
30
|
-
children: children
|
|
31
|
-
});
|
|
32
|
-
}).current;
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=useComponent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","jsx","_jsx","NavigationContent","render","children","useComponent","renderRef","useRef","current","useEffect","Error"],"sourceRoot":"../../src","sources":["useComponent.tsx"],"mappings":";;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAS/B,MAAMC,iBAAiB,GAAGA,CAAC;EAAEC,MAAM;EAAEC;AAAgB,CAAC,KAAK;EACzD,OAAOD,MAAM,CAACC,QAAQ,CAAC;AACzB,CAAC;AAED,OAAO,SAASC,YAAYA,CAACF,MAAc,EAAE;EAC3C,MAAMG,SAAS,GAAGP,KAAK,CAACQ,MAAM,CAAgBJ,MAAM,CAAC;;EAErD;EACA;EACA;EACAG,SAAS,CAACE,OAAO,GAAGL,MAAM;EAE1BJ,KAAK,CAACU,SAAS,CAAC,MAAM;IACpBH,SAAS,CAACE,OAAO,GAAG,IAAI;EAC1B,CAAC,CAAC;EAEF,OAAOT,KAAK,CAACQ,MAAM,CAAC,CAAC;IAAEH;EAAwC,CAAC,KAAK;IACnE,MAAMD,MAAM,GAAGG,SAAS,CAACE,OAAO;IAEhC,IAAIL,MAAM,KAAK,IAAI,EAAE;MACnB,MAAM,IAAIO,KAAK,CACb,+EACF,CAAC;IACH;IAEA,oBAAOT,IAAA,CAACC,iBAAiB;MAACC,MAAM,EAAEA,MAAO;MAAAC,QAAA,EAAEA;IAAQ,CAAoB,CAAC;EAC1E,CAAC,CAAC,CAACI,OAAO;AACZ","ignoreList":[]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
type Render = (children: React.ReactNode) => React.JSX.Element;
|
|
3
|
-
export declare function useComponent(render: Render): ({ children }: {
|
|
4
|
-
children: React.ReactNode;
|
|
5
|
-
}) => React.JSX.Element;
|
|
6
|
-
export {};
|
|
7
|
-
//# sourceMappingURL=useComponent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useComponent.d.ts","sourceRoot":"","sources":["../../../src/useComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,KAAK,MAAM,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,KAAK,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;AAW/D,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,kBAYN;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,uBAWjE"}
|
package/src/useComponent.tsx
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
type Render = (children: React.ReactNode) => React.JSX.Element;
|
|
4
|
-
|
|
5
|
-
type Props = {
|
|
6
|
-
render: Render;
|
|
7
|
-
children: React.ReactNode;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const NavigationContent = ({ render, children }: Props) => {
|
|
11
|
-
return render(children);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export function useComponent(render: Render) {
|
|
15
|
-
const renderRef = React.useRef<Render | null>(render);
|
|
16
|
-
|
|
17
|
-
// Normally refs shouldn't be mutated in render
|
|
18
|
-
// But we return a component which will be rendered
|
|
19
|
-
// So it's just for immediate consumption
|
|
20
|
-
renderRef.current = render;
|
|
21
|
-
|
|
22
|
-
React.useEffect(() => {
|
|
23
|
-
renderRef.current = null;
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
return React.useRef(({ children }: { children: React.ReactNode }) => {
|
|
27
|
-
const render = renderRef.current;
|
|
28
|
-
|
|
29
|
-
if (render === null) {
|
|
30
|
-
throw new Error(
|
|
31
|
-
'The returned component must be rendered in the same render phase as the hook.'
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return <NavigationContent render={render}>{children}</NavigationContent>;
|
|
36
|
-
}).current;
|
|
37
|
-
}
|