-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Description
Description
We're using RN 0.44 in combination with React 16.0.0-alpha.6, so that we can have sticky section headers on Android. It works! However, when the number of rows in the dataSource changes, the section header mysteriously disappears.
Unfortunately, the versions of React and RN used on the Snack website are older, but I still created a sample app that, if the site were to feature the upgraded versions of React and RN, should reproduce the problem: https://snack.expo.io/SkohIU4WZ
What we expect here is for the section header to not only stick on Android, but also not to disappear, should the number of rows in its dataSource change. (iOS works perfectly, for what that's worth.)
Reproduction Steps and Sample Code
List all the steps required to reproduce the issue you're reporting. These steps should be clear and concise.
<ListView
dataSource={dataSource}
enableEmptySections={true}
removeClippedSubviews={false}
renderSectionHeader={() => {
return (
<View style={{height: 100, width, backgroundColor: 'red'}}>
<Text>TEST SECTION</Text>
</View>
);
}}
renderRow={row => {
return <View style={{height: 40, width, backgroundColor: 'white'}}><Text>{row.name}</Text></View>;
}}
renderHeader={() => {
return (
<View style={{height: 50, width, backgroundColor: 'yellow'}}>
<Text>THIS IS THE LISTVIEW HEADER</Text>
</View>
);
}}
stickySectionHeadersEnabled={true}
/>Solution
I've combed through react-native/Libraries/Lists/ListView.js, and I'm unable to find the cause. It appears we always enter the if case on line 411: https://github.com/facebook/react-native/blob/master/Libraries/Lists/ListView/ListView.js#L410
And we always end up having a section header element, which gets pushed onto the bodyComponents array. It's just that it visually disappears, when the number of rows in dataSource changes.
Unfortunately, I don't know the root cause of the bug. :-(
Additional Information
- React Native version: 0.44.0
- Platform: Android
- Development Operating System: MacOS
- Dev tools: Android API levels 19, 22 and 23 have been tested