Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] - Error when using scalar values as items for Select #2938

Open
jegork opened this issue May 3, 2024 · 2 comments · May be fixed by #2953
Open

[BUG] - Error when using scalar values as items for Select #2938

jegork opened this issue May 3, 2024 · 2 comments · May be fixed by #2953
Assignees

Comments

@jegork
Copy link

jegork commented May 3, 2024

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

Copy link

linear bot commented May 3, 2024

@ryo-manba ryo-manba self-assigned this May 5, 2024
@ryo-manba
Copy link
Member

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,

See: WeakMap - JavaScript | MDN

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants