-4
{storeAvailableHours.map((e,i) => {

                    return(
                    <Dropdown.Item as="button" onClick= {() => {setOrderIndex(i)}} >
                    {e.dayOfWeek}
                    </Dropdown.Item>
                    )

                 })}

Hi, everyone. I got a warning "Warning: Each child in a list should have a unique "key" prop" for this map function. Do you have any idea how to fix it? Thank you very much.

Frances
  • 23
  • 3
  • https://reactjs.org/docs/lists-and-keys.html#basic-list-component – Robin Zigmond Feb 24 '21 at 23:16
  • 3
    Did you Google the error and read the other million posts about this? Did you read up about what the "key" prop is in React - what it means and when you need it? Google is your friend – Jayce444 Feb 24 '21 at 23:23

1 Answers1

0

You should set the key prop to the item.

<Dropdown.Item key={i} as="button" onClick= {() => {setOrderIndex(i)}} >
 {e.dayOfWeek}
</Dropdown.Item>