question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FlatList can't scroll

See original GitHub issue

Description

on android component FlatList can’t be scrolled, and I got warning like this

Warning: Cannot record touch end without a touch start.
Touch End: {"identifier":0,"pageX":0,"pageY":0,"timestamp":1641956304238}
Touch Bank: [null,{"touchActive":true,"startPageX":278.0859375,"startPageY":212.92410278320312,"startTimeStamp":1641956304179,"currentPageX":267.91754150390625,"currentPageY":213.75302124023438,"currentTimeStamp":1641956304236,"previousPageX":276.943359375,"previousPageY":212.92410278320312,"previousTimeStamp":1641956304219}]

when using Flatlist directly from gestureHandler and adding props shouldActivateOnStart it just runs and it’s not wrapped with Animated.createAnimatedComponent(FlatList)

Screenshots

Steps To Reproduce

  1. Basically I just put Flatlist inside ListHeaderComponents in Flatlist.
  2. wrapping the Flatlist RN component with Animated.createAnimatedComponent(FlatList) from reanimated

Expected behavior

it should work as expected

Actual behavior

component can’t be scrolled and get a warning like above

Snack or minimal code example

// HeaderList.tsx
import { FlatList, FlatListProps, StyleProp, ViewStyle } from 'react-native';

import Animated from 'react-native-reanimated';

const AFlatList = Animated.createAnimatedComponent(FlatList);

const { x, scrollHandler } = useScrollHandler(); // from redash
// can't be scrolled
...
<AnimatedFlatList
          {...scrollHandler}
          data={[...]}
          keyExtractor={keyExtractor}
          horizontal
          contentContainerStyle={{ paddingVertical: 10 }}
          pagingEnabled
          decelerationRate="fast"
          showsHorizontalScrollIndicator={false}
          renderItem={renderItem}
          onMomentumScrollEnd={({ nativeEvent: { contentOffset, contentSize } }) => {
            const selected = IndicatorSlider.getSelected(contentOffset.x, contentSize.width, tiers.tiers.length);
            activeIndex.setValue(selected);
          }}
        />
...
// its works
import { FlatList } from 'react-native-gesture-handler';
<FlatList
          ListEmptyComponent={PointCardEmpty}
          data={[...]}
          keyExtractor={keyExtractor}
          horizontal
          contentContainerStyle={{ paddingVertical: 10 }}
          pagingEnabled
          shouldActivateOnStart // <- add this
          decelerationRate="fast"
          showsHorizontalScrollIndicator={false}
          renderItem={renderItem}
          onMomentumScrollEnd={({ nativeEvent: { contentOffset, contentSize } }) => {
            const selected = IndicatorSlider.getSelected(contentOffset.x, contentSize.width, tiers.tiers.length);
            activeIndex.setValue(selected);
          }}
        />
// cartList.tsx

 <AnimatedFlatList
        ListHeaderComponent={HeaderList}
        showsVerticalScrollIndicator={false}
        initialNumToRender={100}
        data={[...]}
        renderItem={renderItem}
        ItemSeparatorComponent={() => <VBox h={2} background={colors.lineColor} mx={16} />}
        contentContainerStyle={styles.container}
        ListHeaderComponentStyle={{ marginBottom: 20 }}
      />

Package versions

  • React: 17.0.2
  • React Native: 0.65.2
  • React Native Gesture Handler: 2.0.0, 2.1.0, 2.1.1

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kmagieracommented, Mar 31, 2022

Hi @dodicandra – would be great to have that small reproducible example from you to make any progress on this issue.

On top of that, it isn’t recommended to use createAnimatedComponent on FlatList. Note that FlatList is a “virtual” component that renders ScrollView under the hood, and createAnimatedComponent really makes sense only when run on components that map directly to native views. If you want to use animated props for the ScrollView that FlatList controlls you should use renderScrollComponent prop (see https://reactnative.dev/docs/virtualizedlist#renderscrollcomponent)

1reaction
j-piaseckicommented, Jan 24, 2022

Could you prepare a repository with a reproduction of these issues so I can look into it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

FlatList not scrolling - Stack Overflow
i have created a screen where I display a component that contains a FlatList. For some reason I can't scroll through the list....
Read more >
Issue: Scrolling horizontal FlatList - CodeSandbox
Activating extension 'vscode.typescript-language-features' failed: Could not find bundled tsserver.js.
Read more >
Displaying a List in React Native: Map Method or FlatList ...
FlatList is a React Native component that provides scrolling features by default. ... But you can't see all the data because the list...
Read more >
ScrollView - React Native
This is where FlatList comes into play. FlatList renders items lazily, when they are about to appear, and removes items that scroll way...
Read more >
How to Fix 'VirtualizedLists should never be nested inside ...
To fix the warning discussed earlier, you can simply remove the ScrollView and place all the components that surround the FlatList inside the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found