react-native-gifted-listview icon indicating copy to clipboard operation
react-native-gifted-listview copied to clipboard

React Native 0.23.1 warning: 'In next release empty section headers will be rendered'

Open benvium opened this issue 9 years ago • 7 comments

Since upgrading I'm now getting this error.

My setup looks like this:

<GiftedListView style={{flex:1}}
                                automaticallyAdjustContentInsets={false}
                                rowView={this._renderRow}
                                onFetch={this._loadDataFromNetwork}
                                firstLoader={true}
                                pagination={false}
                                refreshable={true}
                                withSections={false}
                                customStyles={{refreshableView:{backgroundColor: '#FFFFFF'}}}
                                emptyView={this._renderEmptyView}
                                ref="listView"

                />

e.g. I'm using withSections={false}. Any ideas?

benvium avatar Apr 14 '16 17:04 benvium

The full error message is: Warning: In next release empty section headers will be rendered. In this release you can use 'enableEmptySections' flag to render empty section headers.

This flag is referenced in the documentation of the ListView. I'm not sure how @FaridSafi would like to solve the issue, but currently it is possible to mute the error passing it the flag, knowing that at some point the flag will be deprecated. Anyways @benvium, as a temporary fix insert the following line while calling GiftedListView: enableEmptySections={true}.

jeromegrosse avatar Apr 15 '16 07:04 jeromegrosse

Thanks @jeromegrosse, that works, at least until the next version of React Native.

benvium avatar Apr 15 '16 08:04 benvium

in the next release, we're supposed to exclude the indices from the sectionID object:

https://facebook.github.io/react-native/docs/listview.html#enableemptysections

But what does that mean? Where will we exclude the indices? Where is the sectionID object? I don't see it in the source code.

faceyspacey avatar Apr 21 '16 07:04 faceyspacey

If empty sections are not desired to be rendered their indices should be excluded from sectionID object.

AFAIK, this is just a confusing way of saying that in the future if you don't want the headers for empty sections to show up, don't include that sectionId in the data blob you passed to cloneWithRowsAndSections. If you use cloneWithRows then you don't have sections and so there's no issue with section headers showing up. The confusing part is that even if you don't use sections, it will still throw the warning mentioning sections. In this case, you can just set enableEmptySections={true} and forget about it.

https://github.com/facebook/react-native/blob/master/Libraries/CustomComponents/ListView/ListViewDataSource.js http://moduscreate.com/react-native-listview-with-section-headers/

eremzeit avatar May 05 '16 04:05 eremzeit

enableEmptySections={true} work for me, thanks #jeromegrosse

dalvik31 avatar Aug 22 '16 01:08 dalvik31

I am using the new FlatList and passing that prop didn't work ... maybe it doesn't get pass later to the ListView component. So ... I commented the warning in the ListView.js file located in .../node_modules/react-native/Libraries/Lists/ListView/ListView.js line 433-437. It is not the best solution .. but we know the warning exists and it doesn't pops up anymore. I hope someone finds it useful.

mgarc729 avatar Feb 24 '18 20:02 mgarc729

I did like @mgarc729 but clearly if there is better solution, I'm here !

yelkamel avatar Mar 24 '18 17:03 yelkamel