I'm fairly new to react-native. I encountered a problem with dynamic rendering of components.
I'm using a swiper component. When there is only one card to be rendered i get a warning:
"Warning: Encountered two children with the same key, 0
. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted — the behavior is unsupported and could change in a future version."
Everything works fine when there is more than one card to be rendered but when there is only one card to be rendered I get the warning.
I read this : Understanding unique keys for array children in React.js
But its not really making sense to me :(
I also posted my question here :
https://github.com/alexbrillant/react-native-deck-swiper/issues/90
Any help would be appreciated!
Thanks
Edit: added code.
Screenshots of my code is in the links above but I think the most relevant code would be :
cards.push(<MyPetCard
petId={responseJson[x].petId}
petName={responseJson[x].name}
breed={responseJson[x].breed}
gender={responseJson[x].gender}
category={responseJson[x].category}
description={responseJson[x].description}
birthday={responseJson[x].birthday}
imageInfo={image}
petAge={responseJson[x].age}
distance={petDistance}
significantValue={responseJson[x].significant}
/>);