flatlistRef.scrollToOffset is not a function
See original GitHub issueIssue Description
Describe the bug When I drag an item to edge of the screen to activate scrolling to drag beyond the visible bounds, I get the following error:
TypeError: flatlistRef.scrollToOffset is not a function
The error originates along the lines:
_this.scrollToAsync = function (offset) {
return new Promise(function (resolve) {
_this.resolveAutoscroll = resolve;
This used to work a few weeks ago. I’ve updated my package.json to latest versions of all packages and this error started appearing. But I don’t know updating/changing what really broke this as I realized it today.
To Reproduce Have a draggable flat list with items exceeding screen height. Try to drag an item to activate scroll threshold. It should normally start dragging the list up/down to drag the currently item anywhere on screen. Instead, it gives the warning above and doesn’t scroll the list.
Platform & Dependencies Please list any applicable dependencies in addition to those below (react-navigation etc).
- Platform: iOS 14.5
- React Native or Expo version: React Native 0.64
- Reanimated version: 1.13.2
- React Native Gesture Handler version: 1.10.3
Additional context This wasn’t the issue before and it used to scroll correctly before. It happened within a few weeks where I’ve updated many dependencies (and I don’t know at which exact point this got broken as we weren’t testing this part of the app).
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:7 (1 by maintainers)
According to this SO answer, we could use
flatlistRef.getNode()
to get the underlying component. So as a quick fix (before the official fix), we could updatenode_modules/react-native-draggable-flatlist/lib/index.js
to this:
Then preserve the patch with:
fixed in 2.6.2 https://github.com/computerjazz/react-native-draggable-flatlist/releases/tag/v2.6.2