NativeBase: Select.Item Key prop missing
Description
I have the error key prop missing on the select component
CodeSandBox/Snack link
https://snack.expo.dev/@grean/nativebaseselectkeypropissue
Steps to reproduce
Don’t know if you can see the react native errors log with the snak. I was not successful with seeing them…
NativeBase Version
3.3.2
Platform
- Android
- CRA
- Expo
- iOS
- Next
Other Platform
No response
Additional Information
No error on the Web part. Here my code However, the key prop is here.
const orders = Array.from({ length: executionCount }, (_, i) => (i + 1).toString())
<Select
selectedValue={order.toString()}
flex={0.5}
// minWidth="200"
accessibilityLabel="Choose Service"
placeholder="Choose Service"
mt={1}
_selectedItem={{
bg: colors.primary[200],
endIcon: <CheckIcon size="5" />,
}}
// onValueChange={(itemValue) => setService(itemValue)}
>
{
orders.map(order => <Select.Item
key={order}
label={order}
value={order}
/>)
}
</Select>
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 21
Hi everyone, Thanks for reporting the issue. We’re working on it.
Thanks @kcrt for the workaround, it worked for me. The problem is with the default dropdown icon coming with the Select component. I did almost the same, but with an Icon component using Ionicons from @expo/vector-icons. This solution will remove the key props warning:
Thanks!
I also have the error warning
I’m sorry but i continue to get this error message:
It’s more related to the ForwardRef(createdIcon). I should post the message before sorry for that. I think this issue #4429 is related too
Hi everyone, This issue is fixed in
3.4.0. Let me know if this doesn’t work for you.snack does not show local warning like “should have a unique key prop”, even with simple example like:
In local development environment with native-base 3.3.4, this issue still persists under iOS. This problem does not occur in web mode. As mentioned in https://github.com/GeekyAnts/NativeBase/issues/4429#issuecomment-1001768489 ,
SVGIconwithoutkeyprop increateIconseems to cause this problem. https://github.com/GeekyAnts/NativeBase/blob/2af374e586034366dcefce9a0f23983836a7901f/src/components/primitives/Icon/createIcon.tsx#L14For a workaround, I use
dropdownIcon={<Text>↓</Text>}to tell avoid usingChevronDownIcon.We’re working on this. Thanks for your patience.
Thanks @jharteaga no more warning. Maybe solving the warning with the default component could be cool.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.