-
Notifications
You must be signed in to change notification settings - Fork 1k
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
LabeledValue is throwing for a null value #5001
Comments
Looks like we should add a case for if (value == null) {
children = 'null';
} above this line
and then add Assuming we want to render the string 'null' in this case. |
But in our case |
What would you expect to be rendered? I think the string You can always handle these cases yourself and transform it into something that makes sense for your use case before it gets rendered by the component. |
I think re-using 'None' from Picker would be better. 'null' is quite specific to us javascript programmers. To the end user, I think saying 'None' would make more sense, as it communicates there is no value. Otherwise, I'd suggest using a string value instead https://react-spectrum.adobe.com/react-spectrum/LabeledValue.html#label-alignment-and-position and providing the translated string you want for a particular type of empty value |
We do not intend to put |
Couldn't you do something like |
Yes we can do that as a workaround, but it seems better to fix it in the component to not have the component crash for a |
To be fair, null is not documented as a valid value (and errors in TypeScript strict mode at least), and it's not obvious what we would render in case null is passed. You'd likely want to control that anyway, and it's easy to do that already. |
We had already planned to add a control since we have to prevent our app from crashing because of this. But I thought this should be reported as it seemed like the real fix for the long term to not have the component crash. In our stack the component didn't error out and we saw the crash in prod. Why is it not ok to add a check on the value before |
Provide a general summary of the issue here
<LabeledValue value={null} />
is throwing this error:🤔 Expected Behavior?
<LabeledValue value={null} />
should not throw😯 Current Behavior
The app page crashes
💁 Possible Solution
In the code do not use
typeof value === 'object'
because it'strue
fornull
or verify value is notnull
.🔦 Context
We use LabeledValue with values that can be set to null by our third party form engine so it's difficult to make an exception just for this case to have the form engine not set null values when there is no value.
🖥️ Steps to Reproduce
Try
<LabeledValue value={null} />
Version
3.22.0
What browsers are you seeing the problem on?
Chrome
If other, please specify.
No response
What operating system are you using?
MacOS Monterey
🧢 Your Company/Team
Adobe Journey Optimizer
🕷 Tracking Issue
No response
The text was updated successfully, but these errors were encountered: