Skip to content

Commit

Permalink
Convert ResponderEventPlugin to createRoot (#28190)
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon authored and gaearon committed Feb 3, 2024
1 parent 205abe0 commit 6e1e92f
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1377,11 +1377,12 @@ describe('ResponderEventPlugin', () => {
expect(ResponderEventPlugin._getResponder()).toBe(null);
});

it('should determine the first common ancestor correctly', () => {
it('should determine the first common ancestor correctly', async () => {
// This test was moved here from the ReactTreeTraversal test since only the
// ResponderEventPlugin uses `getLowestCommonAncestor`
const React = require('react');
const ReactTestUtils = require('react-dom/test-utils');
const ReactDOMClient = require('react-dom/client');
const act = require('internal-test-utils').act;
const getLowestCommonAncestor =
require('react-native-renderer/src/legacy-events/ResponderEventPlugin').getLowestCommonAncestor;
// This works by accident and will likely break in the future.
Expand Down Expand Up @@ -1422,7 +1423,12 @@ describe('ResponderEventPlugin', () => {
}
}

const parent = ReactTestUtils.renderIntoDocument(<ParentComponent />);
const container = document.createElement('div');
const root = ReactDOMClient.createRoot(container);
let parent;
await act(() => {
root.render(<ParentComponent ref={current => (parent = current)} />);
});

const ancestors = [
// Common ancestor with self is self.
Expand Down

0 comments on commit 6e1e92f

Please sign in to comment.