@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.
Files changed (95) hide show
  1. package/assets/fonts/MaterialSymbolsOutlined.codepoints +11 -0
  2. package/assets/fonts/MaterialSymbolsOutlined_100.ttf +0 -0
  3. package/assets/fonts/MaterialSymbolsOutlined_200.ttf +0 -0
  4. package/assets/fonts/MaterialSymbolsOutlined_300.ttf +0 -0
  5. package/assets/fonts/MaterialSymbolsOutlined_400.ttf +0 -0
  6. package/assets/fonts/MaterialSymbolsOutlined_500.ttf +0 -0
  7. package/assets/fonts/MaterialSymbolsOutlined_600.ttf +0 -0
  8. package/assets/fonts/MaterialSymbolsOutlined_700.ttf +0 -0
  9. package/assets/fonts/MaterialSymbolsRounded.codepoints +11 -0
  10. package/assets/fonts/MaterialSymbolsRounded_100.ttf +0 -0
  11. package/assets/fonts/MaterialSymbolsRounded_200.ttf +0 -0
  12. package/assets/fonts/MaterialSymbolsRounded_300.ttf +0 -0
  13. package/assets/fonts/MaterialSymbolsRounded_400.ttf +0 -0
  14. package/assets/fonts/MaterialSymbolsRounded_500.ttf +0 -0
  15. package/assets/fonts/MaterialSymbolsRounded_600.ttf +0 -0
  16. package/assets/fonts/MaterialSymbolsRounded_700.ttf +0 -0
  17. package/assets/fonts/MaterialSymbolsSharp.codepoints +11 -0
  18. package/assets/fonts/MaterialSymbolsSharp_100.ttf +0 -0
  19. package/assets/fonts/MaterialSymbolsSharp_200.ttf +0 -0
  20. package/assets/fonts/MaterialSymbolsSharp_300.ttf +0 -0
  21. package/assets/fonts/MaterialSymbolsSharp_400.ttf +0 -0
  22. package/assets/fonts/MaterialSymbolsSharp_500.ttf +0 -0
  23. package/assets/fonts/MaterialSymbolsSharp_600.ttf +0 -0
  24. package/assets/fonts/MaterialSymbolsSharp_700.ttf +0 -0
  25. package/lib/module/NavigationContainer.js +55 -16
  26. package/lib/module/NavigationContainer.js.map +1 -1
  27. package/lib/module/checkSerializable.js +180 -0
  28. package/lib/module/checkSerializable.js.map +1 -0
  29. package/lib/module/getStateBreadcrumb.js +37 -0
  30. package/lib/module/getStateBreadcrumb.js.map +1 -0
  31. package/lib/module/native/CornerInset.js.map +1 -1
  32. package/lib/module/native/MaterialSymbol.android.js +4 -4
  33. package/lib/module/native/MaterialSymbol.android.js.map +1 -1
  34. package/lib/module/native/MaterialSymbol.js.map +1 -1
  35. package/lib/module/native/MaterialSymbolViewNativeComponent.ts +1 -1
  36. package/lib/module/native/ReactNavigationCornerInsetViewNativeComponent.ts +2 -4
  37. package/lib/module/native/SFSymbol.ios.js +2 -4
  38. package/lib/module/native/SFSymbol.ios.js.map +1 -1
  39. package/lib/module/native/SFSymbol.js.map +1 -1
  40. package/lib/module/native/SFSymbolViewNativeComponent.ts +1 -1
  41. package/lib/module/useLinkBuilder.js +3 -11
  42. package/lib/module/useLinkBuilder.js.map +1 -1
  43. package/lib/module/useScrollToTop.js +0 -6
  44. package/lib/module/useScrollToTop.js.map +1 -1
  45. package/lib/module/useThenable.js +8 -6
  46. package/lib/module/useThenable.js.map +1 -1
  47. package/lib/typescript/src/NavigationContainer.d.ts +6 -2
  48. package/lib/typescript/src/NavigationContainer.d.ts.map +1 -1
  49. package/lib/typescript/src/checkSerializable.d.ts +12 -0
  50. package/lib/typescript/src/checkSerializable.d.ts.map +1 -0
  51. package/lib/typescript/src/getStateBreadcrumb.d.ts +3 -0
  52. package/lib/typescript/src/getStateBreadcrumb.d.ts.map +1 -0
  53. package/lib/typescript/src/native/CornerInset.d.ts +6 -2
  54. package/lib/typescript/src/native/CornerInset.d.ts.map +1 -1
  55. package/lib/typescript/src/native/MaterialSymbol.android.d.ts +8 -3
  56. package/lib/typescript/src/native/MaterialSymbol.android.d.ts.map +1 -1
  57. package/lib/typescript/src/native/MaterialSymbol.d.ts +7 -2
  58. package/lib/typescript/src/native/MaterialSymbol.d.ts.map +1 -1
  59. package/lib/typescript/src/native/MaterialSymbolData.d.ts +1 -1
  60. package/lib/typescript/src/native/MaterialSymbolData.d.ts.map +1 -1
  61. package/lib/typescript/src/native/MaterialSymbolViewNativeComponent.d.ts +1 -1
  62. package/lib/typescript/src/native/MaterialSymbolViewNativeComponent.d.ts.map +1 -1
  63. package/lib/typescript/src/native/ReactNavigationCornerInsetViewNativeComponent.d.ts +2 -2
  64. package/lib/typescript/src/native/ReactNavigationCornerInsetViewNativeComponent.d.ts.map +1 -1
  65. package/lib/typescript/src/native/SFSymbol.d.ts +7 -2
  66. package/lib/typescript/src/native/SFSymbol.d.ts.map +1 -1
  67. package/lib/typescript/src/native/SFSymbol.ios.d.ts +8 -3
  68. package/lib/typescript/src/native/SFSymbol.ios.d.ts.map +1 -1
  69. package/lib/typescript/src/native/SFSymbolViewNativeComponent.d.ts +1 -1
  70. package/lib/typescript/src/native/SFSymbolViewNativeComponent.d.ts.map +1 -1
  71. package/lib/typescript/src/types.d.ts +14 -5
  72. package/lib/typescript/src/types.d.ts.map +1 -1
  73. package/lib/typescript/src/useLinkBuilder.d.ts.map +1 -1
  74. package/lib/typescript/src/useScrollToTop.d.ts +0 -2
  75. package/lib/typescript/src/useScrollToTop.d.ts.map +1 -1
  76. package/lib/typescript/src/useThenable.d.ts +1 -1
  77. package/lib/typescript/src/useThenable.d.ts.map +1 -1
  78. package/package.json +5 -4
  79. package/src/NavigationContainer.tsx +88 -26
  80. package/src/checkSerializable.tsx +246 -0
  81. package/src/getStateBreadcrumb.tsx +44 -0
  82. package/src/native/CornerInset.ios.tsx +1 -1
  83. package/src/native/CornerInset.tsx +6 -2
  84. package/src/native/MaterialSymbol.android.tsx +9 -4
  85. package/src/native/MaterialSymbol.tsx +7 -2
  86. package/src/native/MaterialSymbolData.tsx +11 -0
  87. package/src/native/MaterialSymbolViewNativeComponent.ts +1 -1
  88. package/src/native/ReactNavigationCornerInsetViewNativeComponent.ts +2 -4
  89. package/src/native/SFSymbol.ios.tsx +7 -4
  90. package/src/native/SFSymbol.tsx +7 -2
  91. package/src/native/SFSymbolViewNativeComponent.ts +1 -1
  92. package/src/types.tsx +14 -5
  93. package/src/useLinkBuilder.tsx +3 -18
  94. package/src/useScrollToTop.tsx +0 -7
  95. package/src/useThenable.tsx +9 -7
@@ -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 [promise] = React.useState(create);
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 (promise == null) {
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
- promise.then((result) => {
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 promise;
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
- }, [promise, resolved]);
49
+ }, [value, resolved]);
48
50
 
49
51
  return state;
50
52
  }