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

Supporting unwanted undefined in object #61

Closed
TommySorensen opened this issue Nov 30, 2022 · 1 comment
Closed

Supporting unwanted undefined in object #61

TommySorensen opened this issue Nov 30, 2022 · 1 comment

Comments

@TommySorensen
Copy link

Is there any plans for supporting this use case?

clsx({undefined: false});

Will return undefined which is unwanted.

Im using clsx in a React.js solution with CSS Modules like this:

 <section
      className={clsx(
        styles.test,
        { [styles[someOtherThing!]]: !!someOtherThing }
      )}
    >

In this case someOtherThing can be undefined or null and since i am doing !!someOtherThing then clsx should never return the "undefined" value.

@lukeed
Copy link
Owner

lukeed commented Nov 30, 2022

It wouldn’t show up with false, so here !!someOtherThing is evaluating to true. And “undefined” is always a string when used as a key name. See #40 for more explanation — it’s native JS and is due to the [undefined]: true syntax

@lukeed lukeed closed this as not planned Won't fix, can't repro, duplicate, stale Nov 30, 2022
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

No branches or pull requests

2 participants