#need help with Listboxitem from nextUI

5 messages · Page 1 of 1 (latest)

north tendon
#

In the following code, cities is an array containing city names. These names aren't necessarily unique. When I map through it, I need to provide key prop to the returned JSX code. So its producing erro here since keys aren't unique. But i can't provide any other as key here, because Listboxitem takes key as its value

fading thistleBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

north tendon
#
                                    onAction={(key) =>
                                        setSelectedCity(key as string)
                                    }>
                                    {cities.map((city) => (
                                        <ListboxItem
                                            key={city}
                                            color="primary"
                                            className="text-primary-500">
                                            {city}
                                        </ListboxItem>

                                    ))}
                                </Listbox>```
#

here is listbox code from nextui/orgr

#

how do I fix this? please help