Answer the question
In order to leave comments, you need to log in
Where in this case to take the keys for the elements?
Good day.
I'm writing a React Native weather app.
I'm making an API request, and then I'm rendering weather components using the .map() method.
But I don't know where to get the key for the key property.
Response items don't have a key
Please tell me how to set the keys in this case?
Answer the question
In order to leave comments, you need to log in
In this case, just take it in order:
data.map((elem, i) => <Component data={elem} key={i}/>)
You can use the element index if you don't mean deleting the array elements.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question