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

Use createRoot in useFocus-test #28083

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Use createRoot in useFocus-test
  • Loading branch information
Jack Pope committed Jan 25, 2024
commit 886d6382936d52476cea5f75188036e502822e6b
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {createEventTarget, setPointerEvent} from 'dom-event-testing-library';

let React;
let ReactFeatureFlags;
let ReactDOM;
let ReactDOMClient;
let useFocus;
let act;

Expand All @@ -23,7 +23,7 @@ function initializeModules(hasPointerEvents) {
ReactFeatureFlags = require('shared/ReactFeatureFlags');
ReactFeatureFlags.enableCreateEventHandleAPI = true;
React = require('react');
ReactDOM = require('react-dom');
ReactDOMClient = require('react-dom/client');
act = require('internal-test-utils').act;
// TODO: This import throws outside of experimental mode. Figure out better
// strategy for gated imports.
Expand All @@ -45,7 +45,6 @@ describe.each(table)(`useFocus hasPointerEvents=%s`, hasPointerEvents => {
});

afterEach(() => {
ReactDOM.render(null, container);
document.body.removeChild(container);
container = null;
});
Expand All @@ -65,8 +64,9 @@ describe.each(table)(`useFocus hasPointerEvents=%s`, hasPointerEvents => {
});
return <div ref={ref} />;
};
const root = ReactDOMClient.createRoot(container);
await act(() => {
ReactDOM.render(<Component />, container);
root.render(<Component />);
});
};

Expand All @@ -93,8 +93,9 @@ describe.each(table)(`useFocus hasPointerEvents=%s`, hasPointerEvents => {
});
return <div ref={ref} />;
};
const root = ReactDOMClient.createRoot(container);
await act(() => {
ReactDOM.render(<Component />, container);
root.render(<Component />);
});
};

Expand Down Expand Up @@ -125,8 +126,9 @@ describe.each(table)(`useFocus hasPointerEvents=%s`, hasPointerEvents => {
</div>
);
};
const root = ReactDOMClient.createRoot(container);
await act(() => {
ReactDOM.render(<Component />, container);
root.render(<Component />);
});
};

Expand Down Expand Up @@ -164,8 +166,9 @@ describe.each(table)(`useFocus hasPointerEvents=%s`, hasPointerEvents => {
</div>
);
};
const root = ReactDOMClient.createRoot(container);
await act(() => {
ReactDOM.render(<Component />, container);
root.render(<Component />);
});
};

Expand Down Expand Up @@ -209,8 +212,9 @@ describe.each(table)(`useFocus hasPointerEvents=%s`, hasPointerEvents => {
</div>
);
};
const root = ReactDOMClient.createRoot(container);
await act(() => {
ReactDOM.render(<Component />, container);
root.render(<Component />);
});
};

Expand Down Expand Up @@ -305,8 +309,9 @@ describe.each(table)(`useFocus hasPointerEvents=%s`, hasPointerEvents => {
);
};

const root = ReactDOMClient.createRoot(container);
await act(() => {
ReactDOM.render(<Outer />, container);
root.render(<Outer />);
});
const innerTarget = createEventTarget(innerRef.current);
const outerTarget = createEventTarget(outerRef.current);
Expand Down