@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
@@ -0,0 +1,246 @@
1
+ type Success = { serializable: true };
2
+
3
+ type Failure = {
4
+ serializable: false;
5
+ location: (string | number)[];
6
+ reason: string;
7
+ };
8
+
9
+ type Result = Success | Failure;
10
+
11
+ const SERIALIZABLE: Success = { serializable: true };
12
+
13
+ const isPlainObject = (o: object): o is Record<string, unknown> => {
14
+ const prototype = Object.getPrototypeOf(o);
15
+
16
+ return (
17
+ prototype === null ||
18
+ prototype === Object.prototype ||
19
+ Object.getPrototypeOf(prototype) === null
20
+ );
21
+ };
22
+
23
+ const isSerializablePrimitive = (o: unknown) =>
24
+ typeof o === 'boolean' ||
25
+ typeof o === 'string' ||
26
+ (typeof o === 'number' && Number.isFinite(o) && !Object.is(o, -0));
27
+
28
+ const checkValue = (o: unknown, ancestors: object[]): Failure | undefined => {
29
+ switch (typeof o) {
30
+ case 'boolean':
31
+ case 'string':
32
+ return undefined;
33
+
34
+ case 'number':
35
+ if (Number.isFinite(o) && !Object.is(o, -0)) {
36
+ return undefined;
37
+ }
38
+
39
+ return {
40
+ serializable: false,
41
+ location: [],
42
+ reason: Object.is(o, -0) ? 'Negative zero' : String(o),
43
+ };
44
+
45
+ case 'function':
46
+ return {
47
+ serializable: false,
48
+ location: [],
49
+ reason: 'Function',
50
+ };
51
+
52
+ case 'bigint':
53
+ return {
54
+ serializable: false,
55
+ location: [],
56
+ reason: 'BigInt',
57
+ };
58
+
59
+ case 'undefined':
60
+ return {
61
+ serializable: false,
62
+ location: [],
63
+ reason: 'Undefined',
64
+ };
65
+
66
+ case 'object':
67
+ if (o === null) {
68
+ return undefined;
69
+ }
70
+
71
+ break;
72
+
73
+ default:
74
+ return {
75
+ serializable: false,
76
+ location: [],
77
+ reason: String(o),
78
+ };
79
+ }
80
+
81
+ const isArray = Array.isArray(o);
82
+ const isPlainArray =
83
+ isArray &&
84
+ (Object.getPrototypeOf(o) === Array.prototype ||
85
+ Array.isArray(Object.getPrototypeOf(o)));
86
+
87
+ if ((isArray && !isPlainArray) || (!isArray && !isPlainObject(o))) {
88
+ const objectType = Object.prototype.toString.call(o).slice(8, -1);
89
+ let reason = objectType;
90
+
91
+ if (isArray) {
92
+ reason = 'Array subclass';
93
+ } else if (objectType === 'Object') {
94
+ reason = 'Object with a custom prototype';
95
+ }
96
+
97
+ return {
98
+ serializable: false,
99
+ location: [],
100
+ reason,
101
+ };
102
+ }
103
+
104
+ if (ancestors.includes(o)) {
105
+ return {
106
+ serializable: false,
107
+ reason: 'Circular reference',
108
+ location: [],
109
+ };
110
+ }
111
+
112
+ ancestors.push(o);
113
+
114
+ if (isArray) {
115
+ const keys = Object.keys(o);
116
+
117
+ const isClean =
118
+ keys.length === o.length &&
119
+ (o.length === 0 || keys[o.length - 1] === String(o.length - 1));
120
+
121
+ if (isClean) {
122
+ const symbols = Object.getOwnPropertySymbols(o);
123
+
124
+ if (symbols.length > 0) {
125
+ return {
126
+ serializable: false,
127
+ location: [String(symbols[0])],
128
+ reason: 'Extra array property',
129
+ };
130
+ }
131
+ } else {
132
+ const names = Object.getOwnPropertyNames(o);
133
+ const symbols = Object.getOwnPropertySymbols(o);
134
+
135
+ if (names.length + symbols.length > o.length + 1) {
136
+ for (const key of names) {
137
+ if (key === 'length') {
138
+ continue;
139
+ }
140
+
141
+ const index = Number(key);
142
+
143
+ if (
144
+ !Number.isInteger(index) ||
145
+ index < 0 ||
146
+ index >= o.length ||
147
+ String(index) !== key
148
+ ) {
149
+ return {
150
+ serializable: false,
151
+ location: [key],
152
+ reason: 'Extra array property',
153
+ };
154
+ }
155
+ }
156
+
157
+ if (symbols.length > 0) {
158
+ return {
159
+ serializable: false,
160
+ location: [String(symbols[0])],
161
+ reason: 'Extra array property',
162
+ };
163
+ }
164
+ }
165
+ }
166
+
167
+ for (let i = 0; i < o.length; i++) {
168
+ if (!isClean && !Object.hasOwn(o, i)) {
169
+ return {
170
+ serializable: false,
171
+ location: [i],
172
+ reason: 'Sparse array',
173
+ };
174
+ }
175
+
176
+ const value = o[i];
177
+
178
+ if (value === null || isSerializablePrimitive(value)) {
179
+ continue;
180
+ }
181
+
182
+ const childResult = checkValue(value, ancestors);
183
+
184
+ if (childResult) {
185
+ childResult.location.push(i);
186
+ return childResult;
187
+ }
188
+ }
189
+ } else {
190
+ const keys = Object.keys(o);
191
+ const names = Object.getOwnPropertyNames(o);
192
+
193
+ if (keys.length !== names.length) {
194
+ for (const key of names) {
195
+ if (!Object.prototype.propertyIsEnumerable.call(o, key)) {
196
+ return {
197
+ serializable: false,
198
+ location: [key],
199
+ reason: 'Non-enumerable property',
200
+ };
201
+ }
202
+ }
203
+ }
204
+
205
+ const symbols = Object.getOwnPropertySymbols(o);
206
+
207
+ if (symbols.length > 0) {
208
+ return {
209
+ serializable: false,
210
+ location: [String(symbols[0])],
211
+ reason: 'Symbol key',
212
+ };
213
+ }
214
+
215
+ for (const key of keys) {
216
+ const value = o[key];
217
+
218
+ if (value == null || isSerializablePrimitive(value)) {
219
+ continue;
220
+ }
221
+
222
+ const childResult = checkValue(value, ancestors);
223
+
224
+ if (childResult) {
225
+ childResult.location.push(key);
226
+ return childResult;
227
+ }
228
+ }
229
+ }
230
+
231
+ ancestors.pop();
232
+
233
+ return undefined;
234
+ };
235
+
236
+ export function checkSerializable(o: unknown): Result {
237
+ const result = checkValue(o, []);
238
+
239
+ if (!result) {
240
+ return SERIALIZABLE;
241
+ }
242
+
243
+ result.location.reverse();
244
+
245
+ return result;
246
+ }
@@ -0,0 +1,44 @@
1
+ import type { NavigationState } from '@react-navigation/core';
2
+
3
+ export function getStateBreadcrumb(
4
+ state: NavigationState,
5
+ location: (string | number)[]
6
+ ) {
7
+ let breadcrumb = '';
8
+ let pointer: Record<any, any> = state;
9
+ let params = false;
10
+
11
+ for (let i = 0; i < location.length; i++) {
12
+ const curr = location[i];
13
+ const prev = location[i - 1];
14
+
15
+ if (curr == null) {
16
+ continue;
17
+ }
18
+
19
+ pointer = pointer[curr];
20
+
21
+ if (!params && curr === 'state') {
22
+ continue;
23
+ } else if (!params && curr === 'routes') {
24
+ if (breadcrumb) {
25
+ breadcrumb += ' > ';
26
+ }
27
+ } else if (!params && typeof curr === 'number' && prev === 'routes') {
28
+ breadcrumb += pointer?.name;
29
+ } else if (!params) {
30
+ breadcrumb += ` > ${curr}`;
31
+ params = true;
32
+ } else {
33
+ if (typeof curr === 'number' || /^[0-9]+$/.test(curr)) {
34
+ breadcrumb += `[${curr}]`;
35
+ } else if (/^[a-z$_]+$/i.test(curr)) {
36
+ breadcrumb += `.${curr}`;
37
+ } else {
38
+ breadcrumb += `[${JSON.stringify(curr)}]`;
39
+ }
40
+ }
41
+ }
42
+
43
+ return breadcrumb;
44
+ }
@@ -17,7 +17,7 @@ export function CornerInset({ ref, ...rest }: Props) {
17
17
 
18
18
  const nativeRef =
19
19
  React.useRef<
20
- React.ElementRef<typeof ReactNavigationCornerInsetViewNativeComponent>
20
+ React.ComponentRef<typeof ReactNavigationCornerInsetViewNativeComponent>
21
21
  >(null);
22
22
 
23
23
  const relayout = React.useCallback(() => {
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import type { ViewProps } from 'react-native';
2
+ import type { ViewStyle } from 'react-native';
3
3
 
4
4
  export type CornerInsetProps = {
5
5
  /**
@@ -17,7 +17,11 @@ export type CornerInsetProps = {
17
17
  * @default true
18
18
  */
19
19
  adaptive?: boolean;
20
- } & Omit<ViewProps, 'children'>;
20
+ /**
21
+ * Style object for the inset view.
22
+ */
23
+ style?: ViewStyle | undefined;
24
+ };
21
25
 
22
26
  export type CornerInsetRef = {
23
27
  relayout(): void;
@@ -2,7 +2,7 @@ import {
2
2
  type ImageSourcePropType,
3
3
  PixelRatio,
4
4
  processColor,
5
- type ViewProps,
5
+ type ViewStyle,
6
6
  } from 'react-native';
7
7
 
8
8
  import { FONT_WEIGHTS } from './constants';
@@ -10,19 +10,25 @@ import MaterialSymbolViewNativeComponent from './MaterialSymbolViewNativeCompone
10
10
  import NativeMaterialSymbolModule from './NativeMaterialSymbolModule';
11
11
  import type { MaterialSymbolOptions } from './types';
12
12
 
13
- export type MaterialSymbolProps = MaterialSymbolOptions & ViewProps;
13
+ export type MaterialSymbolProps = MaterialSymbolOptions & {
14
+ /**
15
+ * Style object for the symbol.
16
+ */
17
+ style?: ViewStyle | undefined;
18
+ };
14
19
 
15
20
  export function MaterialSymbol({
16
21
  name,
22
+ variant,
17
23
  weight,
18
24
  size = 24,
19
25
  color,
20
26
  style,
21
- ...rest
22
27
  }: MaterialSymbolProps): React.ReactElement {
23
28
  return (
24
29
  <MaterialSymbolViewNativeComponent
25
30
  name={name}
31
+ variant={variant}
26
32
  weight={typeof weight === 'string' ? FONT_WEIGHTS[weight] : (weight ?? 0)}
27
33
  size={size}
28
34
  color={color}
@@ -33,7 +39,6 @@ export function MaterialSymbol({
33
39
  },
34
40
  style,
35
41
  ]}
36
- {...rest}
37
42
  />
38
43
  );
39
44
  }
@@ -1,8 +1,13 @@
1
- import type { ImageSourcePropType, ViewProps } from 'react-native';
1
+ import type { ImageSourcePropType, ViewStyle } from 'react-native';
2
2
 
3
3
  import type { MaterialSymbolOptions } from './types';
4
4
 
5
- export type MaterialSymbolProps = MaterialSymbolOptions & ViewProps;
5
+ export type MaterialSymbolProps = MaterialSymbolOptions & {
6
+ /**
7
+ * Style object for the symbol.
8
+ */
9
+ style?: ViewStyle | undefined;
10
+ };
6
11
 
7
12
  export function MaterialSymbol(_: MaterialSymbolProps): React.ReactElement {
8
13
  throw new Error('MaterialSymbol is only supported on Android.');
@@ -1231,6 +1231,7 @@ export type MaterialSymbolName =
1231
1231
  | 'drone'
1232
1232
  | 'drone_2'
1233
1233
  | 'dropdown'
1234
+ | 'dropdown_menu'
1234
1235
  | 'dropper_eye'
1235
1236
  | 'dry'
1236
1237
  | 'dry_cleaning'
@@ -1387,6 +1388,7 @@ export type MaterialSymbolName =
1387
1388
  | 'eyeglasses'
1388
1389
  | 'eyeglasses_2'
1389
1390
  | 'eyeglasses_2_sound'
1391
+ | 'eyeglasses_3'
1390
1392
  | 'face'
1391
1393
  | 'face_2'
1392
1394
  | 'face_3'
@@ -1858,6 +1860,7 @@ export type MaterialSymbolName =
1858
1860
  | 'high_chair'
1859
1861
  | 'high_density'
1860
1862
  | 'high_quality'
1863
+ | 'high_quality_off'
1861
1864
  | 'high_res'
1862
1865
  | 'highlight'
1863
1866
  | 'highlight_alt'
@@ -2015,6 +2018,7 @@ export type MaterialSymbolName =
2015
2018
  | 'japanese_curry'
2016
2019
  | 'japanese_flag'
2017
2020
  | 'javascript'
2021
+ | 'jewelry'
2018
2022
  | 'join'
2019
2023
  | 'join_full'
2020
2024
  | 'join_inner'
@@ -3100,6 +3104,7 @@ export type MaterialSymbolName =
3100
3104
  | 'request_page'
3101
3105
  | 'request_quote'
3102
3106
  | 'reset_brightness'
3107
+ | 'reset_colors'
3103
3108
  | 'reset_exposure'
3104
3109
  | 'reset_focus'
3105
3110
  | 'reset_image'
@@ -3234,8 +3239,10 @@ export type MaterialSymbolName =
3234
3239
  | 'seat_cool_right'
3235
3240
  | 'seat_heat_left'
3236
3241
  | 'seat_heat_right'
3242
+ | 'seat_read'
3237
3243
  | 'seat_vent_left'
3238
3244
  | 'seat_vent_right'
3245
+ | 'seat_window'
3239
3246
  | 'security'
3240
3247
  | 'security_key'
3241
3248
  | 'security_update'
@@ -3309,6 +3316,7 @@ export type MaterialSymbolName =
3309
3316
  | 'settings_photo_camera'
3310
3317
  | 'settings_power'
3311
3318
  | 'settings_remote'
3319
+ | 'settings_screen'
3312
3320
  | 'settings_seating'
3313
3321
  | 'settings_slow_motion'
3314
3322
  | 'settings_suggest'
@@ -3377,6 +3385,7 @@ export type MaterialSymbolName =
3377
3385
  | 'side_navigation'
3378
3386
  | 'sign_language'
3379
3387
  | 'sign_language_2'
3388
+ | 'sign_language_off'
3380
3389
  | 'signal_cellular_0_bar'
3381
3390
  | 'signal_cellular_1_bar'
3382
3391
  | 'signal_cellular_2_bar'
@@ -3410,6 +3419,7 @@ export type MaterialSymbolName =
3410
3419
  | 'sim_card_alert'
3411
3420
  | 'sim_card_download'
3412
3421
  | 'simulation'
3422
+ | 'single_arrow'
3413
3423
  | 'single_bed'
3414
3424
  | 'sip'
3415
3425
  | 'siren'
@@ -3446,6 +3456,7 @@ export type MaterialSymbolName =
3446
3456
  | 'smoking_rooms'
3447
3457
  | 'sms'
3448
3458
  | 'sms_failed'
3459
+ | 'snail'
3449
3460
  | 'snippet_folder'
3450
3461
  | 'snooze'
3451
3462
  | 'snowboarding'
@@ -2,7 +2,7 @@
2
2
 
3
3
  import {
4
4
  codegenNativeComponent,
5
- CodegenTypes,
5
+ type CodegenTypes,
6
6
  type ColorValue,
7
7
  type ViewProps,
8
8
  } from 'react-native';
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import {
4
4
  codegenNativeCommands,
5
5
  codegenNativeComponent,
6
- CodegenTypes,
6
+ type CodegenTypes,
7
7
  type HostComponent,
8
8
  type ViewProps,
9
9
  } from 'react-native';
@@ -15,9 +15,7 @@ export interface NativeProps extends ViewProps {
15
15
  }
16
16
 
17
17
  interface NativeCommands {
18
- // FIXME: codegen fails with ComponentRef
19
- // so we currently use the deprecated ElementRef
20
- relayout(viewRef: React.ElementRef<HostComponent<NativeProps>>): void;
18
+ relayout(viewRef: React.ComponentRef<HostComponent<NativeProps>>): void;
21
19
  }
22
20
 
23
21
  export const Commands = codegenNativeCommands<NativeCommands>({
@@ -1,4 +1,4 @@
1
- import type { ViewProps } from 'react-native';
1
+ import type { ViewStyle } from 'react-native';
2
2
 
3
3
  import { FONT_WEIGHTS } from './constants';
4
4
  import SFSymbolViewNativeComponent from './SFSymbolViewNativeComponent';
@@ -16,7 +16,12 @@ import type {
16
16
  SFSymbolReplaceTransitionVariant,
17
17
  } from './types';
18
18
 
19
- export type SFSymbolProps = SFSymbolOptions & ViewProps;
19
+ export type SFSymbolProps = SFSymbolOptions & {
20
+ /**
21
+ * Style object for the symbol.
22
+ */
23
+ style?: ViewStyle | undefined;
24
+ };
20
25
 
21
26
  type NativeEffectConfig = {
22
27
  type: SFSymbolEffectName;
@@ -54,7 +59,6 @@ export function SFSymbol({
54
59
  effect,
55
60
  contentTransition,
56
61
  style,
57
- ...rest
58
62
  }: SFSymbolProps): React.ReactElement {
59
63
  const effectConfig: NativeEffectConfig | undefined =
60
64
  typeof effect === 'string' ? { type: effect } : effect;
@@ -106,7 +110,6 @@ export function SFSymbol({
106
110
  },
107
111
  style,
108
112
  ]}
109
- {...rest}
110
113
  />
111
114
  );
112
115
  }
@@ -1,8 +1,13 @@
1
- import type { ViewProps } from 'react-native';
1
+ import type { ViewStyle } from 'react-native';
2
2
 
3
3
  import type { SFSymbolOptions } from './types';
4
4
 
5
- export type SFSymbolProps = SFSymbolOptions & ViewProps;
5
+ export type SFSymbolProps = SFSymbolOptions & {
6
+ /**
7
+ * Style object for the symbol.
8
+ */
9
+ style?: ViewStyle | undefined;
10
+ };
6
11
 
7
12
  export function SFSymbol(_: SFSymbolProps): React.ReactElement {
8
13
  throw new Error('SFSymbol is only supported on iOS.');
@@ -2,7 +2,7 @@
2
2
 
3
3
  import {
4
4
  codegenNativeComponent,
5
- CodegenTypes,
5
+ type CodegenTypes,
6
6
  type ColorValue,
7
7
  type ViewProps,
8
8
  } from 'react-native';
package/src/types.tsx CHANGED
@@ -214,14 +214,23 @@ export type DocumentTitleOptions = {
214
214
 
215
215
  export type Persistor = {
216
216
  /**
217
- * Callback to persist the navigation state.
217
+ * Callback to persist the serialized navigation state.
218
218
  */
219
- persist(state: NavigationState | undefined): void;
219
+ persist: (state: string | undefined) => void | PromiseLike<void>;
220
220
  /**
221
- * Callback to restore the navigation state.
222
- * Should return the restored state or a Promise which resolves to the restored state.
221
+ * Callback to restore the serialized navigation state.
222
+ *
223
+ * Should return the serialized state or a Promise which resolves to the serialized state.
223
224
  *
224
225
  * If a Promise is returned, providing a `fallback` component is recommended.
225
226
  */
226
- restore(): PromiseLike<InitialState | undefined> | InitialState | undefined;
227
+ restore: () => PromiseLike<string | undefined> | string | undefined;
228
+ /**
229
+ * Optional callback to serialize the navigation state.
230
+ */
231
+ stringify?: (state: NavigationState | undefined) => string | undefined;
232
+ /**
233
+ * Optional callback to parse the serialized navigation state.
234
+ */
235
+ parse?: (state: string | undefined) => InitialState | undefined;
227
236
  };
@@ -1,11 +1,9 @@
1
1
  import {
2
2
  CommonActions,
3
- findFocusedRoute,
4
3
  getActionFromState,
5
4
  getPathFromState,
5
+ IsScreenContext,
6
6
  NavigationContainerRefContext,
7
- NavigationHelpersContext,
8
- NavigationRouteContext,
9
7
  useStateForPath,
10
8
  } from '@react-navigation/core';
11
9
  import * as React from 'react';
@@ -27,8 +25,7 @@ type MinimalState = {
27
25
  * Helper to build a href for a screen based on the linking options.
28
26
  */
29
27
  export function useBuildHref() {
30
- const navigation = React.use(NavigationHelpersContext);
31
- const route = React.use(NavigationRouteContext);
28
+ const isScreen = React.use(IsScreenContext);
32
29
 
33
30
  const { options } = React.use(LinkingContext);
34
31
 
@@ -42,17 +39,6 @@ export function useBuildHref() {
42
39
  return undefined;
43
40
  }
44
41
 
45
- // Check that we're inside:
46
- // - navigator's context
47
- // - route context of the navigator (could be a screen, tab, etc.)
48
- // - route matches the state for path (from the screen's context)
49
- // This ensures that we're inside a screen
50
- const isScreen =
51
- navigation && route?.key && focusedRouteState
52
- ? route.key === findFocusedRoute(focusedRouteState)?.key &&
53
- navigation.getState().routes.some((r) => r.key === route.key)
54
- : false;
55
-
56
42
  const stateForRoute: MinimalState = {
57
43
  routes: [{ name, params }],
58
44
  };
@@ -96,8 +82,7 @@ export function useBuildHref() {
96
82
  [
97
83
  options?.enabled,
98
84
  options?.config,
99
- route?.key,
100
- navigation,
85
+ isScreen,
101
86
  focusedRouteState,
102
87
  getPathFromStateHelper,
103
88
  ]
@@ -18,7 +18,6 @@ type ScrollableView =
18
18
 
19
19
  type ScrollableWrapper =
20
20
  | { getScrollResponder(): React.ReactNode | ScrollView }
21
- | { getNode(): ScrollableView }
22
21
  | ScrollableView
23
22
  | null;
24
23
 
@@ -39,12 +38,6 @@ function getScrollableNode(ref: React.RefObject<ScrollableWrapper>) {
39
38
  // If the view is a wrapper like FlatList, SectionList etc.
40
39
  // We need to use `getScrollResponder` to get access to the scroll responder
41
40
  return ref.current.getScrollResponder();
42
- } else if ('getNode' in ref.current) {
43
- // When a `ScrollView` is wrapped in `Animated.createAnimatedComponent`
44
- // we need to use `getNode` to get the ref to the actual scrollview.
45
- // Note that `getNode` is deprecated in newer versions of react-native
46
- // this is why we check if we already have a scrollable node above.
47
- return ref.current.getNode();
48
41
  } else {
49
42
  return ref.current;
50
43
  }