The whole Carousell component can be disappeared due to removeClippedSubviews in FlatList
See original GitHub issueIs 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:
- Created 5 years ago
- Reactions:3
- Comments:7 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@knyuwork By setting
removeClippedSubviews
tofalse
you basically get rid of all theFlatList
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
totrue
instead of going theremoveClippedSubviews
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…
+1