@react-navigation/native 7.0.0-alpha.9 → 7.0.0-rc.0
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/Link.js +9 -10
- package/lib/commonjs/Link.js.map +1 -1
- package/lib/commonjs/LinkingContext.js +1 -1
- package/lib/commonjs/LinkingContext.js.map +1 -1
- package/lib/commonjs/LocaleDirContext.js +1 -1
- package/lib/commonjs/LocaleDirContext.js.map +1 -1
- package/lib/commonjs/NavigationContainer.js +14 -15
- package/lib/commonjs/NavigationContainer.js.map +1 -1
- package/lib/commonjs/ServerContainer.js +5 -6
- package/lib/commonjs/ServerContainer.js.map +1 -1
- package/lib/commonjs/ServerContext.js +1 -1
- package/lib/commonjs/ServerContext.js.map +1 -1
- package/lib/commonjs/UnhandledLinkingContext.js +1 -1
- package/lib/commonjs/UnhandledLinkingContext.js.map +1 -1
- package/lib/commonjs/__stubs__/createStackNavigator.js +7 -4
- package/lib/commonjs/__stubs__/createStackNavigator.js.map +1 -1
- package/lib/commonjs/__stubs__/window.js.map +1 -1
- package/lib/commonjs/createMemoryHistory.js +15 -16
- package/lib/commonjs/createMemoryHistory.js.map +1 -1
- package/lib/commonjs/createStaticNavigation.js +23 -11
- package/lib/commonjs/createStaticNavigation.js.map +1 -1
- package/lib/commonjs/extractPathFromURL.js +1 -1
- package/lib/commonjs/extractPathFromURL.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/theming/DarkTheme.js.map +1 -1
- package/lib/commonjs/theming/DefaultTheme.js.map +1 -1
- package/lib/commonjs/theming/fonts.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/useBackButton.js.map +1 -1
- package/lib/commonjs/useBackButton.native.js +1 -1
- package/lib/commonjs/useBackButton.native.js.map +1 -1
- package/lib/commonjs/useDocumentTitle.js +5 -6
- package/lib/commonjs/useDocumentTitle.js.map +1 -1
- package/lib/commonjs/useDocumentTitle.native.js.map +1 -1
- package/lib/commonjs/useLinkBuilder.js +1 -1
- package/lib/commonjs/useLinkBuilder.js.map +1 -1
- package/lib/commonjs/useLinkProps.js +7 -8
- package/lib/commonjs/useLinkProps.js.map +1 -1
- package/lib/commonjs/useLinkTo.js +1 -1
- package/lib/commonjs/useLinkTo.js.map +1 -1
- package/lib/commonjs/useLinking.js +22 -12
- package/lib/commonjs/useLinking.js.map +1 -1
- package/lib/commonjs/useLinking.native.js +31 -35
- package/lib/commonjs/useLinking.native.js.map +1 -1
- package/lib/commonjs/useLocale.js +1 -1
- package/lib/commonjs/useLocale.js.map +1 -1
- package/lib/commonjs/useScrollToTop.js +2 -2
- package/lib/commonjs/useScrollToTop.js.map +1 -1
- package/lib/commonjs/useThenable.js +1 -1
- package/lib/commonjs/useThenable.js.map +1 -1
- package/lib/commonjs/useUnhandledLinking.js +1 -1
- package/lib/commonjs/useUnhandledLinking.js.map +1 -1
- package/lib/module/Link.js +8 -9
- package/lib/module/Link.js.map +1 -1
- package/lib/module/LinkingContext.js.map +1 -1
- package/lib/module/LocaleDirContext.js.map +1 -1
- package/lib/module/NavigationContainer.js +12 -13
- package/lib/module/NavigationContainer.js.map +1 -1
- package/lib/module/ServerContainer.js +4 -5
- package/lib/module/ServerContainer.js.map +1 -1
- package/lib/module/ServerContext.js.map +1 -1
- package/lib/module/UnhandledLinkingContext.js.map +1 -1
- package/lib/module/__stubs__/createStackNavigator.js +5 -2
- package/lib/module/__stubs__/createStackNavigator.js.map +1 -1
- package/lib/module/__stubs__/window.js.map +1 -1
- package/lib/module/createMemoryHistory.js +15 -16
- package/lib/module/createMemoryHistory.js.map +1 -1
- package/lib/module/createStaticNavigation.js +22 -10
- package/lib/module/createStaticNavigation.js.map +1 -1
- package/lib/module/extractPathFromURL.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/theming/DarkTheme.js.map +1 -1
- package/lib/module/theming/DefaultTheme.js.map +1 -1
- package/lib/module/theming/fonts.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/useBackButton.js.map +1 -1
- package/lib/module/useBackButton.native.js.map +1 -1
- package/lib/module/useDocumentTitle.js +4 -5
- package/lib/module/useDocumentTitle.js.map +1 -1
- package/lib/module/useDocumentTitle.native.js.map +1 -1
- package/lib/module/useLinkBuilder.js.map +1 -1
- package/lib/module/useLinkProps.js +6 -7
- package/lib/module/useLinkProps.js.map +1 -1
- package/lib/module/useLinkTo.js.map +1 -1
- package/lib/module/useLinking.js +20 -10
- package/lib/module/useLinking.js.map +1 -1
- package/lib/module/useLinking.native.js +30 -34
- package/lib/module/useLinking.native.js.map +1 -1
- package/lib/module/useLocale.js.map +1 -1
- package/lib/module/useScrollToTop.js +1 -1
- package/lib/module/useScrollToTop.js.map +1 -1
- package/lib/module/useThenable.js.map +1 -1
- package/lib/module/useUnhandledLinking.js.map +1 -1
- package/lib/typescript/src/LinkingContext.d.ts +1 -1
- package/lib/typescript/src/LinkingContext.d.ts.map +1 -1
- package/lib/typescript/src/NavigationContainer.d.ts +2 -7
- package/lib/typescript/src/NavigationContainer.d.ts.map +1 -1
- package/lib/typescript/src/ServerContainer.d.ts.map +1 -1
- package/lib/typescript/src/UnhandledLinkingContext.d.ts.map +1 -1
- package/lib/typescript/src/__stubs__/createStackNavigator.d.ts +12 -30
- package/lib/typescript/src/__stubs__/createStackNavigator.d.ts.map +1 -1
- package/lib/typescript/src/__stubs__/window.d.ts +2 -2
- package/lib/typescript/src/createMemoryHistory.d.ts.map +1 -1
- package/lib/typescript/src/createStaticNavigation.d.ts +17 -3
- package/lib/typescript/src/createStaticNavigation.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +20 -18
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/useBackButton.d.ts +0 -1
- package/lib/typescript/src/useBackButton.d.ts.map +1 -1
- package/lib/typescript/src/useLinkBuilder.d.ts +2 -2
- package/lib/typescript/src/useLinkProps.d.ts.map +1 -1
- package/lib/typescript/src/useLinking.d.ts +3 -26
- package/lib/typescript/src/useLinking.d.ts.map +1 -1
- package/lib/typescript/src/useLinking.native.d.ts +6 -6
- package/lib/typescript/src/useUnhandledLinking.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/NavigationContainer.tsx +1 -1
- package/src/__stubs__/createStackNavigator.tsx +30 -2
- package/src/createMemoryHistory.tsx +4 -2
- package/src/createStaticNavigation.tsx +58 -8
- package/src/types.tsx +22 -20
- package/src/useLinking.tsx +23 -2
- package/src/useScrollToTop.tsx +1 -1
|
@@ -7,26 +7,26 @@ export declare function useLinking(ref: React.RefObject<NavigationContainerRef<P
|
|
|
7
7
|
key: string;
|
|
8
8
|
index: number;
|
|
9
9
|
routeNames: string[];
|
|
10
|
-
history?: unknown[]
|
|
10
|
+
history?: unknown[];
|
|
11
11
|
routes: import("@react-navigation/core").NavigationRoute<ParamListBase, string>[];
|
|
12
12
|
type: string;
|
|
13
13
|
stale: false;
|
|
14
14
|
}>, "stale" | "routes">> & Readonly<{
|
|
15
|
-
stale?: true
|
|
15
|
+
stale?: true;
|
|
16
16
|
routes: import("@react-navigation/core").PartialRoute<import("@react-navigation/core").Route<string, object | undefined>>[];
|
|
17
17
|
}> & {
|
|
18
|
-
state?:
|
|
18
|
+
state?: Partial<Omit<Readonly<{
|
|
19
19
|
key: string;
|
|
20
20
|
index: number;
|
|
21
21
|
routeNames: string[];
|
|
22
|
-
history?: unknown[]
|
|
22
|
+
history?: unknown[];
|
|
23
23
|
routes: import("@react-navigation/core").NavigationRoute<ParamListBase, string>[];
|
|
24
24
|
type: string;
|
|
25
25
|
stale: false;
|
|
26
26
|
}>, "stale" | "routes">> & Readonly<{
|
|
27
|
-
stale?: true
|
|
27
|
+
stale?: true;
|
|
28
28
|
routes: import("@react-navigation/core").PartialRoute<import("@react-navigation/core").Route<string, object | undefined>>[];
|
|
29
|
-
}> & any
|
|
29
|
+
}> & any;
|
|
30
30
|
}) | undefined>;
|
|
31
31
|
};
|
|
32
32
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUnhandledLinking.d.ts","sourceRoot":"","sources":["../../../src/useUnhandledLinking.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,YAAY,EAClB,MAAM,wBAAwB,CAAC;AA2BhC,wBAAgB,4BAA4B;;gDAU1B,eAAe,KAC5B,
|
|
1
|
+
{"version":3,"file":"useUnhandledLinking.d.ts","sourceRoot":"","sources":["../../../src/useUnhandledLinking.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,YAAY,EAClB,MAAM,wBAAwB,CAAC;AA2BhC,wBAAgB,4BAA4B;;gDAU1B,eAAe,KAC5B,YAAY,CAAC,eAAe,CAAC,GAAG,SAAS;;EA+C7C"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-navigation/native",
|
|
3
3
|
"description": "React Native integration for React Navigation",
|
|
4
|
-
"version": "7.0.0-
|
|
4
|
+
"version": "7.0.0-rc.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
7
7
|
"react-navigation",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"clean": "del lib"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@react-navigation/core": "^7.0.0-
|
|
40
|
+
"@react-navigation/core": "^7.0.0-rc.0",
|
|
41
41
|
"escape-string-regexp": "^4.0.0",
|
|
42
42
|
"fast-deep-equal": "^3.1.3",
|
|
43
43
|
"nanoid": "3.3.7",
|
|
@@ -45,18 +45,18 @@
|
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@testing-library/react-native": "^12.4.3",
|
|
48
|
-
"@types/react": "~18.2.
|
|
49
|
-
"@types/react-dom": "~18.
|
|
48
|
+
"@types/react": "~18.2.79",
|
|
49
|
+
"@types/react-dom": "~18.2.25",
|
|
50
50
|
"del-cli": "^5.1.0",
|
|
51
51
|
"react": "18.2.0",
|
|
52
52
|
"react-dom": "18.2.0",
|
|
53
|
-
"react-native": "0.
|
|
53
|
+
"react-native": "0.74.2",
|
|
54
54
|
"react-native-builder-bob": "^0.23.2",
|
|
55
|
-
"typescript": "^5.
|
|
55
|
+
"typescript": "^5.5.2"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"react": "
|
|
59
|
-
"react-native": "0.
|
|
58
|
+
"react": ">= 18.2.0",
|
|
59
|
+
"react-native": ">= 0.72.0"
|
|
60
60
|
},
|
|
61
61
|
"react-native-builder-bob": {
|
|
62
62
|
"source": "src",
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
]
|
|
73
73
|
]
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "2a1d67089eea2a3d87e38a870ccee35a79c55d7d"
|
|
76
76
|
}
|
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createNavigatorFactory,
|
|
3
|
+
type DefaultNavigatorOptions,
|
|
4
|
+
type NavigationListBase,
|
|
5
|
+
type ParamListBase,
|
|
6
|
+
type StackNavigationState,
|
|
3
7
|
StackRouter,
|
|
8
|
+
type TypedNavigator,
|
|
4
9
|
useNavigationBuilder,
|
|
5
10
|
} from '@react-navigation/core';
|
|
6
11
|
import * as React from 'react';
|
|
7
12
|
|
|
8
|
-
|
|
13
|
+
const StackNavigator = (
|
|
14
|
+
props: DefaultNavigatorOptions<
|
|
15
|
+
ParamListBase,
|
|
16
|
+
string | undefined,
|
|
17
|
+
StackNavigationState<ParamListBase>,
|
|
18
|
+
{},
|
|
19
|
+
{},
|
|
20
|
+
unknown
|
|
21
|
+
>
|
|
22
|
+
) => {
|
|
9
23
|
const { state, descriptors, NavigationContent } = useNavigationBuilder(
|
|
10
24
|
StackRouter,
|
|
11
25
|
props
|
|
@@ -16,4 +30,18 @@ export const createStackNavigator = createNavigatorFactory((props) => {
|
|
|
16
30
|
{descriptors[state.routes[state.index].key].render()}
|
|
17
31
|
</NavigationContent>
|
|
18
32
|
);
|
|
19
|
-
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export function createStackNavigator<
|
|
36
|
+
ParamList extends ParamListBase,
|
|
37
|
+
>(): TypedNavigator<{
|
|
38
|
+
ParamList: ParamList;
|
|
39
|
+
NavigatorID: string | undefined;
|
|
40
|
+
State: StackNavigationState<ParamList>;
|
|
41
|
+
ScreenOptions: {};
|
|
42
|
+
EventMap: {};
|
|
43
|
+
NavigationList: NavigationListBase<ParamList>;
|
|
44
|
+
Navigator: typeof StackNavigator;
|
|
45
|
+
}> {
|
|
46
|
+
return createNavigatorFactory(StackNavigator)();
|
|
47
|
+
}
|
|
@@ -87,6 +87,7 @@ export function createMemoryHistory() {
|
|
|
87
87
|
// Need to keep the hash part of the path if there was no previous history entry
|
|
88
88
|
// or the previous history entry had the same path
|
|
89
89
|
let pathWithHash = path;
|
|
90
|
+
const hash = pathWithHash.includes('#') ? '' : location.hash;
|
|
90
91
|
|
|
91
92
|
if (!items.length || items.findIndex((item) => item.id === id) < 0) {
|
|
92
93
|
// There are two scenarios for creating an array with only one history record:
|
|
@@ -95,12 +96,13 @@ export function createMemoryHistory() {
|
|
|
95
96
|
// the page when navigating forward in history.
|
|
96
97
|
// - This is the first time any state modifications are done
|
|
97
98
|
// So we need to push the entry as there's nothing to replace
|
|
98
|
-
|
|
99
|
+
|
|
100
|
+
pathWithHash = pathWithHash + hash;
|
|
99
101
|
items = [{ path: pathWithHash, state, id }];
|
|
100
102
|
index = 0;
|
|
101
103
|
} else {
|
|
102
104
|
if (items[index].path === path) {
|
|
103
|
-
pathWithHash = pathWithHash +
|
|
105
|
+
pathWithHash = pathWithHash + hash;
|
|
104
106
|
}
|
|
105
107
|
items[index] = { path, state, id };
|
|
106
108
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createComponentForStaticNavigation,
|
|
3
3
|
createPathConfigForStaticNavigation,
|
|
4
|
+
type NavigationContainerRef,
|
|
4
5
|
type ParamListBase,
|
|
5
6
|
type StaticNavigation,
|
|
6
7
|
} from '@react-navigation/core';
|
|
@@ -16,7 +17,24 @@ type Props = Omit<
|
|
|
16
17
|
/**
|
|
17
18
|
* Options for deep linking.
|
|
18
19
|
*/
|
|
19
|
-
linking?: Omit<LinkingOptions<ParamListBase>, 'config'
|
|
20
|
+
linking?: Omit<LinkingOptions<ParamListBase>, 'config' | 'enabled'> & {
|
|
21
|
+
/**
|
|
22
|
+
* Whether deep link handling should be enabled.
|
|
23
|
+
* Defaults to `true` if any `linking` options are specified, `false` otherwise.
|
|
24
|
+
*
|
|
25
|
+
* When 'auto' is specified, all leaf screens will get a autogenerated path.
|
|
26
|
+
* The generated path will be a kebab-case version of the screen name.
|
|
27
|
+
* This can be overridden for specific screens by specifying `linking` for the screen.
|
|
28
|
+
*/
|
|
29
|
+
enabled?: 'auto' | true | false;
|
|
30
|
+
/**
|
|
31
|
+
* Additional configuration
|
|
32
|
+
*/
|
|
33
|
+
config?: Omit<
|
|
34
|
+
NonNullable<LinkingOptions<ParamListBase>['config']>,
|
|
35
|
+
'screens'
|
|
36
|
+
>;
|
|
37
|
+
};
|
|
20
38
|
};
|
|
21
39
|
|
|
22
40
|
/**
|
|
@@ -28,17 +46,49 @@ type Props = Omit<
|
|
|
28
46
|
*/
|
|
29
47
|
export function createStaticNavigation(tree: StaticNavigation<any, any, any>) {
|
|
30
48
|
const Component = createComponentForStaticNavigation(tree, 'RootNavigator');
|
|
31
|
-
const linkingConfig = {
|
|
32
|
-
screens: tree.config.screens
|
|
33
|
-
? createPathConfigForStaticNavigation(tree)
|
|
34
|
-
: {},
|
|
35
|
-
};
|
|
36
49
|
|
|
37
|
-
function Navigation(
|
|
50
|
+
function Navigation(
|
|
51
|
+
{ linking, ...rest }: Props,
|
|
52
|
+
ref: React.Ref<NavigationContainerRef<ParamListBase>>
|
|
53
|
+
) {
|
|
54
|
+
const screens = React.useMemo(() => {
|
|
55
|
+
if (tree.config.screens) {
|
|
56
|
+
return createPathConfigForStaticNavigation(
|
|
57
|
+
tree,
|
|
58
|
+
{ initialRouteName: linking?.config?.initialRouteName },
|
|
59
|
+
linking?.enabled === 'auto'
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return undefined;
|
|
64
|
+
}, [linking?.config, linking?.enabled]);
|
|
65
|
+
|
|
66
|
+
if (linking?.enabled === true && screens == null) {
|
|
67
|
+
throw new Error(
|
|
68
|
+
'Linking is enabled but no linking configuration was found for the screens.\n\n' +
|
|
69
|
+
'To solve this:\n' +
|
|
70
|
+
"- Specify a 'linking' property for the screens you want to link to.\n" +
|
|
71
|
+
"- Or set 'linking.enabled' to 'auto' to generate paths automatically.\n\n" +
|
|
72
|
+
'See usage guide: https://reactnavigation.org/docs/7.x/static-configuration#linking'
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
38
76
|
return (
|
|
39
77
|
<NavigationContainer
|
|
40
78
|
{...rest}
|
|
41
|
-
|
|
79
|
+
ref={ref}
|
|
80
|
+
linking={
|
|
81
|
+
linking
|
|
82
|
+
? {
|
|
83
|
+
...linking,
|
|
84
|
+
enabled:
|
|
85
|
+
typeof linking.enabled === 'boolean'
|
|
86
|
+
? linking.enabled
|
|
87
|
+
: screens != null,
|
|
88
|
+
config: screens ? { ...linking.config, screens } : undefined,
|
|
89
|
+
}
|
|
90
|
+
: undefined
|
|
91
|
+
}
|
|
42
92
|
>
|
|
43
93
|
<Component />
|
|
44
94
|
</NavigationContainer>
|
package/src/types.tsx
CHANGED
|
@@ -9,28 +9,10 @@ import type {
|
|
|
9
9
|
declare global {
|
|
10
10
|
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
11
11
|
namespace ReactNavigation {
|
|
12
|
-
interface Theme {
|
|
13
|
-
dark: boolean;
|
|
14
|
-
colors: {
|
|
15
|
-
primary: string;
|
|
16
|
-
background: string;
|
|
17
|
-
card: string;
|
|
18
|
-
text: string;
|
|
19
|
-
border: string;
|
|
20
|
-
notification: string;
|
|
21
|
-
};
|
|
22
|
-
fonts: {
|
|
23
|
-
regular: FontStyle;
|
|
24
|
-
medium: FontStyle;
|
|
25
|
-
bold: FontStyle;
|
|
26
|
-
heavy: FontStyle;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
12
|
+
interface Theme extends NativeTheme {}
|
|
29
13
|
}
|
|
30
14
|
}
|
|
31
15
|
|
|
32
|
-
export type LocaleDirection = 'ltr' | 'rtl';
|
|
33
|
-
|
|
34
16
|
type FontStyle = {
|
|
35
17
|
fontFamily: string;
|
|
36
18
|
fontWeight:
|
|
@@ -47,7 +29,27 @@ type FontStyle = {
|
|
|
47
29
|
| '900';
|
|
48
30
|
};
|
|
49
31
|
|
|
50
|
-
|
|
32
|
+
interface NativeTheme {
|
|
33
|
+
dark: boolean;
|
|
34
|
+
colors: {
|
|
35
|
+
primary: string;
|
|
36
|
+
background: string;
|
|
37
|
+
card: string;
|
|
38
|
+
text: string;
|
|
39
|
+
border: string;
|
|
40
|
+
notification: string;
|
|
41
|
+
};
|
|
42
|
+
fonts: {
|
|
43
|
+
regular: FontStyle;
|
|
44
|
+
medium: FontStyle;
|
|
45
|
+
bold: FontStyle;
|
|
46
|
+
heavy: FontStyle;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type Theme = NativeTheme;
|
|
51
|
+
|
|
52
|
+
export type LocaleDirection = 'ltr' | 'rtl';
|
|
51
53
|
|
|
52
54
|
export type LinkingOptions<ParamList extends {}> = {
|
|
53
55
|
/**
|
package/src/useLinking.tsx
CHANGED
|
@@ -280,6 +280,8 @@ export function useLinking(
|
|
|
280
280
|
route: ReturnType<typeof findFocusedRoute>,
|
|
281
281
|
state: NavigationState
|
|
282
282
|
): string => {
|
|
283
|
+
let path;
|
|
284
|
+
|
|
283
285
|
// If the `route` object contains a `path`, use that path as long as `route.name` and `params` still match
|
|
284
286
|
// This makes sure that we preserve the original URL for wildcard routes
|
|
285
287
|
if (route?.path) {
|
|
@@ -296,12 +298,31 @@ export function useLinking(
|
|
|
296
298
|
focusedRoute.name === route.name &&
|
|
297
299
|
isEqual(focusedRoute.params, route.params)
|
|
298
300
|
) {
|
|
299
|
-
|
|
301
|
+
path = route.path;
|
|
300
302
|
}
|
|
301
303
|
}
|
|
302
304
|
}
|
|
303
305
|
|
|
304
|
-
|
|
306
|
+
if (path == null) {
|
|
307
|
+
path = getPathFromStateRef.current(state, configRef.current);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const previousRoute = previousStateRef.current
|
|
311
|
+
? findFocusedRoute(previousStateRef.current)
|
|
312
|
+
: undefined;
|
|
313
|
+
|
|
314
|
+
// Preserve the hash if the route didn't change
|
|
315
|
+
if (
|
|
316
|
+
previousRoute &&
|
|
317
|
+
route &&
|
|
318
|
+
'key' in previousRoute &&
|
|
319
|
+
'key' in route &&
|
|
320
|
+
previousRoute.key === route.key
|
|
321
|
+
) {
|
|
322
|
+
path = path + location.hash;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
return path;
|
|
305
326
|
};
|
|
306
327
|
|
|
307
328
|
if (ref.current) {
|
package/src/useScrollToTop.tsx
CHANGED
|
@@ -39,7 +39,7 @@ function getScrollableNode(ref: React.RefObject<ScrollableWrapper>) {
|
|
|
39
39
|
// We need to use `getScrollResponder` to get access to the scroll responder
|
|
40
40
|
return ref.current.getScrollResponder();
|
|
41
41
|
} else if ('getNode' in ref.current) {
|
|
42
|
-
// When a `ScrollView` is
|
|
42
|
+
// When a `ScrollView` is wrapped in `Animated.createAnimatedComponent`
|
|
43
43
|
// we need to use `getNode` to get the ref to the actual scrollview.
|
|
44
44
|
// Note that `getNode` is deprecated in newer versions of react-native
|
|
45
45
|
// this is why we check if we already have a scrollable node above.
|