hoaphantn7604 / react-native-virtualized-view

React Native Flatlist inside Scrollview
MIT License
26 stars 8 forks source link

Data re-rendering #7

Open ReactNative-AutoAdvisers opened 1 year ago

ReactNative-AutoAdvisers commented 1 year ago

Even focused screen data is re-rendering again and again on every screen tap

dmgcoding commented 1 year ago

I'm kind of experiencing this as well.

LucasTrombim commented 9 months ago

me too

DanielKuhn commented 8 months ago

This is because the ScrollView creates an anonymous function for the ListHeaderComponent prop which is a new component on every render, causing it to get unmounted and remounted again and again. According to the documentation of RN FlatList, the ListHeaderComponent can be a function OR an Element. Changing this to element stops the rerenders.

See https://github.com/hoaphantn7604/react-native-virtualized-view/pull/8 for the fix.

sheggietyn commented 3 months ago

facing this same issues ... unable tp correct it here

DanielKuhn commented 3 months ago

The complete implementation of this package is 10 lines of code! Since the maintainer seems to have abandoned it, you can simply copy the ScrollView implementation and use it directly in your project. Just make sure to adjust the ListHeaderComponent like this: https://github.com/hoaphantn7604/react-native-virtualized-view/pull/8/files to avoid constant re-rendering.