@react-navigation/native 6.1.11 → 6.1.12
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/useScrollToTop.js +5 -3
- package/lib/commonjs/useScrollToTop.js.map +1 -1
- package/lib/module/useScrollToTop.js +6 -4
- package/lib/module/useScrollToTop.js.map +1 -1
- package/lib/typescript/src/useScrollToTop.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/useScrollToTop.tsx +10 -4
|
@@ -30,12 +30,14 @@ function getScrollableNode(ref) {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
function useScrollToTop(ref) {
|
|
33
|
-
const navigation = (
|
|
33
|
+
const navigation = React.useContext(_core.NavigationContext);
|
|
34
34
|
const route = (0, _core.useRoute)();
|
|
35
|
+
if (navigation === undefined) {
|
|
36
|
+
throw new Error("Couldn't find a navigation object. Is your component inside NavigationContainer?");
|
|
37
|
+
}
|
|
35
38
|
React.useEffect(() => {
|
|
36
|
-
|
|
39
|
+
const tabNavigations = [];
|
|
37
40
|
let currentNavigation = navigation;
|
|
38
|
-
|
|
39
41
|
// If the screen is nested inside multiple tab navigators, we should scroll to top for any of them
|
|
40
42
|
// So we need to find all the parent tab navigators and add the listeners there
|
|
41
43
|
while (currentNavigation) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getScrollableNode","ref","current","getScrollResponder","getNode","useScrollToTop","navigation","
|
|
1
|
+
{"version":3,"names":["getScrollableNode","ref","current","getScrollResponder","getNode","useScrollToTop","navigation","React","useContext","NavigationContext","route","useRoute","undefined","Error","useEffect","tabNavigations","currentNavigation","getState","type","push","getParent","length","unsubscribers","map","tab","addListener","e","isFocused","isFirst","includes","routes","key","requestAnimationFrame","scrollable","defaultPrevented","scrollToTop","scrollTo","y","animated","scrollToOffset","offset","scrollResponderScrollTo","forEach","unsubscribe"],"sourceRoot":"../../src","sources":["useScrollToTop.tsx"],"mappings":";;;;;;AAAA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AEC,WAAW,IAAKA,WAAW,EAAE,CAAC;IACvD,CAAC;EACH,CAAC,EAAE,CAACrC,UAAU,EAAEL,GAAG,EAAES,KAAK,CAACqB,GAAG,CAAC,CAAC;AAClC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NavigationContext, useRoute } from '@react-navigation/core';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
function getScrollableNode(ref) {
|
|
4
4
|
if (ref.current == null) {
|
|
@@ -22,12 +22,14 @@ function getScrollableNode(ref) {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
export default function useScrollToTop(ref) {
|
|
25
|
-
const navigation =
|
|
25
|
+
const navigation = React.useContext(NavigationContext);
|
|
26
26
|
const route = useRoute();
|
|
27
|
+
if (navigation === undefined) {
|
|
28
|
+
throw new Error("Couldn't find a navigation object. Is your component inside NavigationContainer?");
|
|
29
|
+
}
|
|
27
30
|
React.useEffect(() => {
|
|
28
|
-
|
|
31
|
+
const tabNavigations = [];
|
|
29
32
|
let currentNavigation = navigation;
|
|
30
|
-
|
|
31
33
|
// If the screen is nested inside multiple tab navigators, we should scroll to top for any of them
|
|
32
34
|
// So we need to find all the parent tab navigators and add the listeners there
|
|
33
35
|
while (currentNavigation) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["NavigationContext","useRoute","React","getScrollableNode","ref","current","getScrollResponder","getNode","useScrollToTop","navigation","useContext","route","undefined","Error","useEffect","tabNavigations","currentNavigation","getState","type","push","getParent","length","unsubscribers","map","tab","addListener","e","isFocused","isFirst","includes","routes","key","requestAnimationFrame","scrollable","defaultPrevented","scrollToTop","scrollTo","y","animated","scrollToOffset","offset","scrollResponderScrollTo","forEach","unsubscribe"],"sourceRoot":"../../src","sources":["useScrollToTop.tsx"],"mappings":"AAAA,SAEEA,iBAAiB,EAGjBC,QAAQ,QACH,wBAAwB;AAC/B,OAAO,KAAKC,KAAK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,WAAW,IAAKA,WAAW,EAAE,CAAC;IACvD,CAAC;EACH,CAAC,EAAE,CAAClC,UAAU,EAAEL,GAAG,EAAEO,KAAK,CAACoB,GAAG,CAAC,CAAC;AAClC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScrollToTop.d.ts","sourceRoot":"","sources":["../../../src/useScrollToTop.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useScrollToTop.d.ts","sourceRoot":"","sources":["../../../src/useScrollToTop.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,KAAK,aAAa,GAAG;IAAE,CAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEpE,KAAK,cAAc,GACf;IAAE,WAAW,IAAI,IAAI,CAAA;CAAE,GACvB;IAAE,QAAQ,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAA;CAAE,GAC1C;IAAE,cAAc,CAAC,OAAO,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAA;CAAE,GAC1E;IAAE,uBAAuB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAA;CAAE,CAAC;AAE9D,KAAK,iBAAiB,GAClB;IAAE,kBAAkB,IAAI,KAAK,CAAC,SAAS,GAAG,UAAU,CAAA;CAAE,GACtD;IAAE,OAAO,IAAI,cAAc,CAAA;CAAE,GAC7B,cAAc,CAAC;AA8BnB,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,iBAAiB,CAAC,QAqExC"}
|
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": "6.1.
|
|
4
|
+
"version": "6.1.12",
|
|
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": "^6.4.
|
|
40
|
+
"@react-navigation/core": "^6.4.11",
|
|
41
41
|
"escape-string-regexp": "^4.0.0",
|
|
42
42
|
"fast-deep-equal": "^3.1.3",
|
|
43
43
|
"nanoid": "^3.1.23"
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
]
|
|
73
73
|
]
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "13d4aa270b301faf07960b4cd861ffc91e9b2c46"
|
|
76
76
|
}
|
package/src/useScrollToTop.tsx
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EventArg,
|
|
3
|
+
NavigationContext,
|
|
3
4
|
NavigationProp,
|
|
4
|
-
|
|
5
|
+
ParamListBase,
|
|
5
6
|
useRoute,
|
|
6
7
|
} from '@react-navigation/core';
|
|
7
8
|
import * as React from 'react';
|
|
@@ -51,13 +52,18 @@ function getScrollableNode(ref: React.RefObject<ScrollableWrapper>) {
|
|
|
51
52
|
export default function useScrollToTop(
|
|
52
53
|
ref: React.RefObject<ScrollableWrapper>
|
|
53
54
|
) {
|
|
54
|
-
const navigation =
|
|
55
|
+
const navigation = React.useContext(NavigationContext);
|
|
55
56
|
const route = useRoute();
|
|
56
57
|
|
|
58
|
+
if (navigation === undefined) {
|
|
59
|
+
throw new Error(
|
|
60
|
+
"Couldn't find a navigation object. Is your component inside NavigationContainer?"
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
57
64
|
React.useEffect(() => {
|
|
58
|
-
|
|
65
|
+
const tabNavigations: NavigationProp<ParamListBase>[] = [];
|
|
59
66
|
let currentNavigation = navigation;
|
|
60
|
-
|
|
61
67
|
// If the screen is nested inside multiple tab navigators, we should scroll to top for any of them
|
|
62
68
|
// So we need to find all the parent tab navigators and add the listeners there
|
|
63
69
|
while (currentNavigation) {
|