oblador / react-native-collapsible

Animated collapsible component for React Native, good for accordions, toggles etc
MIT License
2.43k stars 453 forks source link

Warning: Each child in a list should have a unique "key" prop #367

Open Jinentonik opened 4 years ago

Jinentonik commented 4 years ago

I am receiving this warning when my app is rendered. All of the accordion function works fine.

How do i add key to each child inside accordion?

PauloMello99 commented 3 years ago

If you are trying to render dinamically the children inside the accordion, each one should have its own key, if the child does not have a unique id to set as key to the parent, you can combine the accordion section index with the child index, you must pass to the child parent view

<Child key={childObj.id.toString()} /> or <Child key={${sectionIndex.toString()}_${childIndex.toString()}} />

wahidshadab commented 2 years ago

same here!