Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invariant Violation: A VirtualizedList contains a cell which itself contains more than one VirtualizedList

The complete error is:

Invariant Violation: A VirtualizedList contains a cell which itself contains more than one VirtualizedList of the same orientation as the parent list. You must pass a unique listKey prop to each sibling list.

Every single one of my FlatList components has a keyExtractor prop. Every item within the List from react-native-elements component has a key prop.

Could anyone shed any light on the meaning of this problem?

like image 980
Dan Avatar asked Feb 28 '18 15:02

Dan


5 Answers

As the error says "You must pass a unique listKey prop to each sibling list." A prop like listKey="someUniqueString" to FlatList fixed this error for me

like image 63
Andrada L Avatar answered Oct 22 '22 05:10

Andrada L


I got this error when using nested flat lists.I use listKey instead of keyExtractor.

**listKey={(item, index) => 'D' + index.toString()}**
like image 20
Akila K Gunawardhana Avatar answered Oct 22 '22 05:10

Akila K Gunawardhana


Use ListKey and keyExtractor props in the FlatList to prevent this error OR warning

Example :

  listKey={(item, index) => `_key${index.toString()}`}
  keyExtractor={(item, index) => `_key${index.toString()}`}
like image 7
M.Daniyal Aslam Avatar answered Oct 22 '22 04:10

M.Daniyal Aslam


if you are using FaltList as a nested list of any other FlatList or SectionList then you have to pass a unique value to this props listKey

listKey={this._keyExtractor}

_keyExtractor = (item, index) => {
return this.props.index+"_"+index+'_'+item.id+"_"+moment().valueOf().toString(); 
}
like image 3
Rana Avatar answered Oct 22 '22 05:10

Rana


I got this error. But fixed using unique string

listKey={moment().valueOf().toString()}
like image 1
A Adak Avatar answered Oct 22 '22 03:10

A Adak