Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: getNode() is not needed for scrolling in FlatList contentRef #449

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/PROPS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 1 addition & 5 deletions examples/expo/src/components/modals/FlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
};

Expand Down