@react-navigation/native 8.0.0-alpha.40 → 8.0.0-alpha.42
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/assets/fonts/MaterialSymbolsOutlined.codepoints +11 -0
- package/assets/fonts/MaterialSymbolsOutlined_100.ttf +0 -0
- package/assets/fonts/MaterialSymbolsOutlined_200.ttf +0 -0
- package/assets/fonts/MaterialSymbolsOutlined_300.ttf +0 -0
- package/assets/fonts/MaterialSymbolsOutlined_400.ttf +0 -0
- package/assets/fonts/MaterialSymbolsOutlined_500.ttf +0 -0
- package/assets/fonts/MaterialSymbolsOutlined_600.ttf +0 -0
- package/assets/fonts/MaterialSymbolsOutlined_700.ttf +0 -0
- package/assets/fonts/MaterialSymbolsRounded.codepoints +11 -0
- package/assets/fonts/MaterialSymbolsRounded_100.ttf +0 -0
- package/assets/fonts/MaterialSymbolsRounded_200.ttf +0 -0
- package/assets/fonts/MaterialSymbolsRounded_300.ttf +0 -0
- package/assets/fonts/MaterialSymbolsRounded_400.ttf +0 -0
- package/assets/fonts/MaterialSymbolsRounded_500.ttf +0 -0
- package/assets/fonts/MaterialSymbolsRounded_600.ttf +0 -0
- package/assets/fonts/MaterialSymbolsRounded_700.ttf +0 -0
- package/assets/fonts/MaterialSymbolsSharp.codepoints +11 -0
- package/assets/fonts/MaterialSymbolsSharp_100.ttf +0 -0
- package/assets/fonts/MaterialSymbolsSharp_200.ttf +0 -0
- package/assets/fonts/MaterialSymbolsSharp_300.ttf +0 -0
- package/assets/fonts/MaterialSymbolsSharp_400.ttf +0 -0
- package/assets/fonts/MaterialSymbolsSharp_500.ttf +0 -0
- package/assets/fonts/MaterialSymbolsSharp_600.ttf +0 -0
- package/assets/fonts/MaterialSymbolsSharp_700.ttf +0 -0
- package/lib/module/NavigationContainer.js +55 -16
- package/lib/module/NavigationContainer.js.map +1 -1
- package/lib/module/checkSerializable.js +180 -0
- package/lib/module/checkSerializable.js.map +1 -0
- package/lib/module/getStateBreadcrumb.js +37 -0
- package/lib/module/getStateBreadcrumb.js.map +1 -0
- package/lib/module/native/CornerInset.js.map +1 -1
- package/lib/module/native/MaterialSymbol.android.js +4 -4
- package/lib/module/native/MaterialSymbol.android.js.map +1 -1
- package/lib/module/native/MaterialSymbol.js.map +1 -1
- package/lib/module/native/MaterialSymbolViewNativeComponent.ts +1 -1
- package/lib/module/native/ReactNavigationCornerInsetViewNativeComponent.ts +2 -4
- package/lib/module/native/SFSymbol.ios.js +2 -4
- package/lib/module/native/SFSymbol.ios.js.map +1 -1
- package/lib/module/native/SFSymbol.js.map +1 -1
- package/lib/module/native/SFSymbolViewNativeComponent.ts +1 -1
- package/lib/module/useLinkBuilder.js +3 -11
- package/lib/module/useLinkBuilder.js.map +1 -1
- package/lib/module/useScrollToTop.js +0 -6
- package/lib/module/useScrollToTop.js.map +1 -1
- package/lib/module/useThenable.js +8 -6
- package/lib/module/useThenable.js.map +1 -1
- package/lib/typescript/src/NavigationContainer.d.ts +6 -2
- package/lib/typescript/src/NavigationContainer.d.ts.map +1 -1
- package/lib/typescript/src/checkSerializable.d.ts +12 -0
- package/lib/typescript/src/checkSerializable.d.ts.map +1 -0
- package/lib/typescript/src/getStateBreadcrumb.d.ts +3 -0
- package/lib/typescript/src/getStateBreadcrumb.d.ts.map +1 -0
- package/lib/typescript/src/native/CornerInset.d.ts +6 -2
- package/lib/typescript/src/native/CornerInset.d.ts.map +1 -1
- package/lib/typescript/src/native/MaterialSymbol.android.d.ts +8 -3
- package/lib/typescript/src/native/MaterialSymbol.android.d.ts.map +1 -1
- package/lib/typescript/src/native/MaterialSymbol.d.ts +7 -2
- package/lib/typescript/src/native/MaterialSymbol.d.ts.map +1 -1
- package/lib/typescript/src/native/MaterialSymbolData.d.ts +1 -1
- package/lib/typescript/src/native/MaterialSymbolData.d.ts.map +1 -1
- package/lib/typescript/src/native/MaterialSymbolViewNativeComponent.d.ts +1 -1
- package/lib/typescript/src/native/MaterialSymbolViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/native/ReactNavigationCornerInsetViewNativeComponent.d.ts +2 -2
- package/lib/typescript/src/native/ReactNavigationCornerInsetViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/native/SFSymbol.d.ts +7 -2
- package/lib/typescript/src/native/SFSymbol.d.ts.map +1 -1
- package/lib/typescript/src/native/SFSymbol.ios.d.ts +8 -3
- package/lib/typescript/src/native/SFSymbol.ios.d.ts.map +1 -1
- package/lib/typescript/src/native/SFSymbolViewNativeComponent.d.ts +1 -1
- package/lib/typescript/src/native/SFSymbolViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +14 -5
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/useLinkBuilder.d.ts.map +1 -1
- package/lib/typescript/src/useScrollToTop.d.ts +0 -2
- package/lib/typescript/src/useScrollToTop.d.ts.map +1 -1
- package/lib/typescript/src/useThenable.d.ts +1 -1
- package/lib/typescript/src/useThenable.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/NavigationContainer.tsx +88 -26
- package/src/checkSerializable.tsx +246 -0
- package/src/getStateBreadcrumb.tsx +44 -0
- package/src/native/CornerInset.ios.tsx +1 -1
- package/src/native/CornerInset.tsx +6 -2
- package/src/native/MaterialSymbol.android.tsx +9 -4
- package/src/native/MaterialSymbol.tsx +7 -2
- package/src/native/MaterialSymbolData.tsx +11 -0
- package/src/native/MaterialSymbolViewNativeComponent.ts +1 -1
- package/src/native/ReactNavigationCornerInsetViewNativeComponent.ts +2 -4
- package/src/native/SFSymbol.ios.tsx +7 -4
- package/src/native/SFSymbol.tsx +7 -2
- package/src/native/SFSymbolViewNativeComponent.ts +1 -1
- package/src/types.tsx +14 -5
- package/src/useLinkBuilder.tsx +3 -18
- package/src/useScrollToTop.tsx +0 -7
- package/src/useThenable.tsx +9 -7
package/src/useThenable.tsx
CHANGED
|
@@ -4,19 +4,21 @@ export type Thenable<T> = {
|
|
|
4
4
|
then(onfulfilled?: (value: T) => unknown): PromiseLike<unknown>;
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
export function useThenable<T>(create: () => Thenable<T> | undefined) {
|
|
8
|
-
const [
|
|
7
|
+
export function useThenable<T>(create: () => Thenable<T> | T | undefined) {
|
|
8
|
+
const [value] = React.useState(create);
|
|
9
9
|
|
|
10
10
|
let initialState: [boolean, T | undefined] = [false, undefined];
|
|
11
11
|
|
|
12
|
-
if (
|
|
12
|
+
if (value == null) {
|
|
13
13
|
initialState = [true, undefined];
|
|
14
|
-
} else {
|
|
14
|
+
} else if (typeof value === 'object' && 'then' in value) {
|
|
15
15
|
// Check if our thenable is synchronous
|
|
16
16
|
// eslint-disable-next-line promise/catch-or-return, promise/always-return
|
|
17
|
-
|
|
17
|
+
value.then((result) => {
|
|
18
18
|
initialState = [true, result];
|
|
19
19
|
});
|
|
20
|
+
} else {
|
|
21
|
+
initialState = [true, value];
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
const [state, setState] = React.useState(initialState);
|
|
@@ -29,7 +31,7 @@ export function useThenable<T>(create: () => Thenable<T> | undefined) {
|
|
|
29
31
|
let result;
|
|
30
32
|
|
|
31
33
|
try {
|
|
32
|
-
result = await
|
|
34
|
+
result = await value;
|
|
33
35
|
} finally {
|
|
34
36
|
if (!cancelled) {
|
|
35
37
|
setState([true, result]);
|
|
@@ -44,7 +46,7 @@ export function useThenable<T>(create: () => Thenable<T> | undefined) {
|
|
|
44
46
|
return () => {
|
|
45
47
|
cancelled = true;
|
|
46
48
|
};
|
|
47
|
-
}, [
|
|
49
|
+
}, [value, resolved]);
|
|
48
50
|
|
|
49
51
|
return state;
|
|
50
52
|
}
|