Skip to content

Conversation

@DiegoAndai
Copy link
Member

@DiegoAndai DiegoAndai commented Jun 19, 2024

Closes #39833

Fixes second bug described in #39833 (comment). The first bug was fixed in #42099.

Use the correct type for renderOptions's props callback argument. The type comes from UseAutocompleteReturnValue.

Before: https://codesandbox.io/p/sandbox/39833-render-option-type-next-vd4jpp?file=%2Fsrc%2FDemo.tsx
After: https://codesandbox.io/p/devbox/f27pj7?file=%2Fsrc%2FDemo.tsx%3A7%2C18

@DiegoAndai DiegoAndai added typescript package: material-ui scope: autocomplete Changes related to the autocomplete. This includes ComboBox. needs cherry-pick The PR should be cherry-picked to master after merge. labels Jun 19, 2024
@DiegoAndai DiegoAndai requested a review from aarongarciah June 19, 2024 20:21
@DiegoAndai DiegoAndai self-assigned this Jun 19, 2024
@DiegoAndai DiegoAndai added the integration: react About improving React support. label Jun 19, 2024
@mui-bot
Copy link

mui-bot commented Jun 19, 2024

Netlify deploy preview

https://deploy-preview-42689--material-ui.netlify.app/

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against fe6d0a8

@DiegoAndai
Copy link
Member Author

@aarongarciah I've added the "React 19 support" label so we can add it to all PRs related to React 19, in case we need to backport it from v6 (next) to v5 (master).

I also added the needs cherry-picking label as this is an issue currently affecting users: #39833 (comment)

@DiegoAndai
Copy link
Member Author

Also, I didn't find any other similar type bugs in other components 👍🏼

@DiegoAndai DiegoAndai requested a review from michaldudak June 19, 2024 20:47
}

export type UseAutocompleteGetOptionPropsReturnValue = React.HTMLAttributes<HTMLLIElement> & {
key: any;
Copy link
Member

@aarongarciah aarongarciah Jun 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use the type coming from @types/react?

Suggested change
key: any;
key: React.Key;

Source: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/298040491bdf086e6fbfe3c9eb12fbe96c90b7fc/types/react/index.d.ts#L239-L262

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, yes, but I would keep any as that's the type declared in Base's getOptionProps and we don't want to update that.

Copy link
Member

@aarongarciah aarongarciah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Left a couple of inline comments for your consideration.

@DiegoAndai DiegoAndai removed the request for review from michaldudak June 21, 2024 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration: react About improving React support. needs cherry-pick The PR should be cherry-picked to master after merge. scope: autocomplete Changes related to the autocomplete. This includes ComboBox. typescript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

react 18.3.0 "A props object containing a "key" prop is being spread into JSX"

3 participants