From 2e4895e86287ef31e7f8d2102ce2e23821380289 Mon Sep 17 00:00:00 2001 From: Kumar Gaurav Date: Mon, 29 Aug 2022 13:25:54 +0530 Subject: [PATCH 1/2] FIX: `getNode()` is not needed for scrolling in FlatList `contentRef` Suggested usage throws this error: ``` ERROR TypeError: contentRef.current.getNode is not a function. (In 'contentRef.current.getNode()', 'contentRef.current.getNode' is undefined) ``` Removing `getNode()` fixes this! --- docs/PROPS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/PROPS.md b/docs/PROPS.md index b86aca16..e8acad62 100644 --- a/docs/PROPS.md +++ b/docs/PROPS.md @@ -86,7 +86,7 @@ To find the path to each of the function it will depend what content renderer (S On latest `react-native`, it should: - For the ScrollView: `contentRef.getScrollResponder().scrollTo(...)` or `contentRef.getScrollResponder().scrollToIndex(...)`, etc... -- For the FlatList: `contentRef.current.getNode().scrollToOffset({ animated: true, offset: 0 });`, etc... +- For the FlatList: `contentRef.current.scrollToOffset({ animated: true, offset: 0 });`, etc... - For the SectionList: `contentRef.current.getNode().scrollToLocation(...)`, etc... On older version of react-native, most likely something like `contentRef.getNode().getScrollResponder().scrollTo(...)` for the ScrollView and following the same pattern for the FlatList and SectionList. From 034dc352cd6a12dda37a17609659aa997ad9d312 Mon Sep 17 00:00:00 2001 From: Kumar Gaurav Date: Mon, 29 Aug 2022 13:27:34 +0530 Subject: [PATCH 2/2] FIX: getNode() is not needed for scrolling in FlatList contentRef Suggested usage throws this error: ``` ERROR TypeError: contentRef.current.getNode is not a function. (In 'contentRef.current.getNode()', 'contentRef.current.getNode' is undefined) ``` --- examples/expo/src/components/modals/FlatList.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/examples/expo/src/components/modals/FlatList.js b/examples/expo/src/components/modals/FlatList.js index 8bdf4907..86950107 100644 --- a/examples/expo/src/components/modals/FlatList.js +++ b/examples/expo/src/components/modals/FlatList.js @@ -23,11 +23,7 @@ export const FlatList = forwardRef((_, ref) => { const handleScrollToTop = () => { if (contentRef.current) { - // Old version of react-native, we need to use getNode() - contentRef.current.getNode().getScrollResponder().scrollTo({ - y: 0, - animated: true, - }); + contentRef.current.scrollToOffset({ animated: true, offset: 0 }); } };