Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReactNative SectionList Missing Key Warning [duplicate]

Tags:

react-native

I'm following the ReactNative tutorial on SectionLists (https://facebook.github.io/react-native/docs/using-a-listview.html#content) and have run into a warning message.

The warnings state

"Warning: VirtualizedSectionList: A section you supplied is missing the key property.

"VirtualizedList: missing keys for items, make sure to specify a key property on each item or provide a custom keyExtractor"

Can someone assist in resolving this warning?

Edit So I was able to resolve the first warning by adding a key to the sections

sections={[
            {key: 'D', title: 'D', data: ['Devin']},
            {key: 'J', title: 'J', data: ['Jackson', 'James', 'Jillian',   'Jimmy', 'Joel', 'John', 'Julie']},
          ]}

But am stilling getting the second error for 1 instance.

like image 957
FortuneFaded Avatar asked Nov 07 '22 20:11

FortuneFaded


1 Answers

I came across the same error before. Defining the keyExtractor property solved it for me.

https://facebook.github.io/react-native/docs/sectionlist.html#keyextractor

Have you tried this yet?

like image 144
justelouise Avatar answered Nov 15 '22 13:11

justelouise