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

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

Open
0xknon opened this issue Mar 17, 2019 · 7 comments

Comments

@0xknon
Copy link

0xknon commented Mar 17, 2019

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.

@hmost1
Copy link

hmost1 commented Mar 20, 2019

+1, completely agree.
Had a similar issue where the data via props would change (and a re render was triggered), but the carousel wouldn't show up. Adding removeClippedSubviews={false} fixed this.
Might be worth mentioning in the docs that it defaults to true.

@zinoviev
Copy link

zinoviev commented Apr 2, 2019

Face same issue after RN upgrade from 57.8 to 59.2

@matheuschagas
Copy link

+1

@bd-arc
Copy link
Contributor

bd-arc commented 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...

@MayoudP
Copy link

MayoudP commented Jul 30, 2019

Any update or news on this ?

@ramaguduri
Copy link

+1

@dohooo

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants