nextui
nextui copied to clipboard
[BUG] - Error when using scalar values as `items` for Select
NextUI Version
2.3.6
Describe the bug
When passing an array of scalar values (e.g. number or string) to items of Select, there is the following error raised:
Uncaught TypeError: Invalid value used as weak map key
at WeakMap.set (<anonymous>)
at $eb2240fc39a57fa5$export$bf788dd355e3a401.getFullNode (@nextui-org_react.js?v=8fb50fc1:39976:24)
at getFullNode.next (<anonymous>)
at $eb2240fc39a57fa5$export$bf788dd355e3a401.iterateCollection (@nextui-org_react.js?v=8fb50fc1:39894:21)
at iterateCollection.next (<anonymous>)
at [Symbol.iterator] (@nextui-org_react.js?v=8fb50fc1:40034:16)
at Generator.next (<anonymous>)
at new $a02d57049d202695$export$d085fb9e920b5ca7 (@nextui-org_react.js?v=8fb50fc1:54815:14)
at @nextui-org_react.js?v=8fb50fc1:54841:140
at @nextui-org_react.js?v=8fb50fc1:40062:12
If you pass an array of objects, the error disappears.
Your Example Website or App
No response
Steps to Reproduce the Bug or Issue
<Select items={["first", "second", "third"]}>
{(item) => <SelectItem key={item}>{item}</SelectItem>}
</Select>
Expected behavior
The items param should accept scalar values or restrict the type of the parameter.
Screenshots or Videos
No response
Operating System Version
macOS
Browser
Chrome
Thanks for the issue!
As we use WeakMap internally, we cannot pass primitive values to items prop. We will modify the type to clarify this.
A WeakMap is a collection of key/value pairs whose keys must be objects or non-registered symbols,