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 Feb 1, 2024
1 parent 2dc428f commit 2a45118
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 2a45118

Please sign in to comment.