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.

The whole Carousell component can be disappeared due to removeClippedSubviews in FlatList

See original GitHub issue

Is this a bug report, a feature request, or a question?

bug report

My Component is like this:

 renderItem = ({ item }) => {
    const { value } = this.props
    if (item === 'overall') {
      return (
        <View style={styles.container}>
          <Text>{value}</Text>
        </View>
      )
    } else {
      return (
        <View style={styles.chartContainer}>
  
        </View>
      )
    }
  }

render() {
  const data = ['overall', 'chart']
  return (
          <Carousel
            data={data}
            renderItem={this.renderItem}
            keyExtractor={keyExtractor}
            sliderWidth={SCREEN_WIDTH}
            itemWidth={SCREEN_WIDTH - 24}
          />
  )
}

Problem

In the above code, this.props.value comes from redux store

Whenever this.props.value is updated, the entire Carousel component will be disappeared.

Solution

I have traced the code and I found that _getComponentOverridableProps in Carousel.js contains removeClippedSubviews: true. After I removed this props, The problem is gone.

And I also referenced to FlatList.

There is a note under removeClippedSubviews:

Note: May have bugs (missing content) in some circumstances - use at your own risk.

Just to share my findings.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:3
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
bd-arccommented, Apr 16, 2019

@knyuwork By setting removeClippedSubviews to false you basically get rid of all the FlatList optimizations and load every single one of your items at once.

This is not a problem if you only have a few of them, but this might become a real issue otherwise.

By the way, you could just set prop useScrollView to true instead of going the removeClippedSubviews route.

Unfortunately, this is a pure RN bug on which we have absolutely no control. In fact, we’ve been trying to compensate for those bugs for years without any luck…

1reaction
ramaguduricommented, Nov 2, 2019

+1

Read more comments on GitHub >

github_iconTop Results From Across the Web

The whole Carousell component can be disappeared due to ...
I have traced the code and I found that _getComponentOverridableProps in Carousel.js contains removeClippedSubviews: true . After I removed this ...
Read more >
Let's create a carousel in React Native - DEV Community ‍ ‍
Let's get started. The base of our carousel will be a simple FlatList component. The reason for this is simple - it's based...
Read more >
Building a Smooth Image Carousel with FlatList in React Native
Below, I'm going to show you how to build an image carousel with React Native's <FlatList /> core component. Users will be able...
Read more >
React-Native FlatList performance problems with large list
VirtualizedList is the component behind FlatList , and is React ... your list is being stored in memory, which could lead to a...
Read more >
Swiper component for React Native with previews, snapping ...
0 of the plugin, with FlatList 's implementation and parallax images. react-native-snap-carousel archriss aix. Archriss' showcase app. You can ...
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