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

[mui-utils][test] Remove usages of deprecated react-dom APIs #42780

Open
wants to merge 2 commits into
base: next
Choose a base branch
from

Conversation

aarongarciah
Copy link
Member

In preparation for #42047, we need to remove react-dom deprecated APIs, namely, render and unmountComponentAtNode. This PR replaces these APIs with createRenderer, our React Testing Library wrapper.

@aarongarciah aarongarciah added test package: utils (private) Specific to the private @mui/utils package React 19 support PRs required to support React 19 labels Jun 28, 2024
@aarongarciah aarongarciah mentioned this pull request Jun 28, 2024
14 tasks
@mui-bot
Copy link

mui-bot commented Jun 28, 2024

Netlify deploy preview

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

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against f51b56d

@aarongarciah aarongarciah force-pushed the remove-react-dom-deprecated-apis branch from 0312f13 to c16bd9f Compare June 28, 2024 11:02
@aarongarciah aarongarciah marked this pull request as draft June 28, 2024 11:16
@aarongarciah aarongarciah force-pushed the remove-react-dom-deprecated-apis branch from c16bd9f to 21d1ff5 Compare June 28, 2024 11:21
@aarongarciah aarongarciah marked this pull request as ready for review June 28, 2024 11:31
Copy link
Member

@DiegoAndai DiegoAndai left a comment

Choose a reason for hiding this comment

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

Getting closer and closer to React 18.3 🎉

let rootNode: HTMLElement;

function assertPass(element: any, { shouldMount = true } = {}) {
async function assertPass(element: any, { shouldMount = true } = {}) {
Copy link
Member

Choose a reason for hiding this comment

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

What is asynchronous? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

await waitFor

Copy link
Member

Choose a reason for hiding this comment

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

I see, I got confused thinking await waitFor was outside of assertPass 😅

waitFor is suggested for lazy components, is React.Suspense using lazy initialization? I'm not very familiar with its implementation 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

My understanding is that React.Suspense + waitFor are only required because of the "accepts lazy" test, which renders a React.lazy component. Kinda weird we use this approach when only a single test requires it, but then the assertPass abstraction falls apart.

Maybe we can simplify assertPass and just not use it for "accepts lazy". I tried to leave unnecessary changes out of this PR but it's kinda difficult with the assertPass abstraction.

@aarongarciah aarongarciah added the needs cherry-pick The PR should be cherry-picked to master after merge label Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs cherry-pick The PR should be cherry-picked to master after merge package: utils (private) Specific to the private @mui/utils package React 19 support PRs required to support React 19 test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants