-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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]: Incorrect typescript for renderSelectedItem property of the Dropdown component #14847
Comments
Thanks for opening this!
I think that's a reasonable approach, feel free to put that into a PR and we can get it reviewed and merged. |
hey @tay1orjones can I work on this? |
I am still getting type error for Carbon Version - @carbon/react : 1.48.0 Error message
Element or ReactNode is not supporting. |
Looks like the fix done was not correct, the
This is saying that
( |
Package
@carbon/react
Browser
Firefox
Package version
v9.6.5
React version
v17.0.2
Description
The intention for the renderSelectedItem property of the Dropdown component is specified in PR #10188. It allows the user to specify a function that returns JSX element instead of the default string. However, the typescript for this property is currently defined as a function that returns string instead of a JSX element. This causes my React code to give an error since it specifies a function that returns a JSX element. I propose that the typescript be changed to:
renderSelectedItem?: React.JSXElementConstructor;
This is similar to what is being done for the itemToElement property
Reproduction/example
NA
Steps to reproduce
The Dropdown below will cause a typescript error, since the renderSelectedItem property is expecting a function that returns a string.
<Dropdown
id="someid"
titleText=""
hideLabel={true}
size="sm"
items={someItems}
label=""
renderSelectedItem={(item: { id: string; label: string }) => {
return
}}
itemToElement={(item: { id: string; label: string }) => {
return
}}
/>
Suggested Severity
Severity 2 = User cannot complete task, and/or no workaround within the user experience of a given component.
Application/PAL
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: