Convert ResponderEventPlugin to createRoot (#28190)
Sebastian Silbermann committed
Feb 2, 2024 at 00:53 UTC
2a45118b1039bc81a44bad81f8e3b1fb2395da1b
1 file changed
+9
-3
packages/react-native-renderer/src/__tests__/ResponderEventPlugin-test.internal.js
+9
-3
@@ -1377,11 +1377,12 @@ describe('ResponderEventPlugin', () => {
1377
expect(ResponderEventPlugin._getResponder()).toBe(null);
1378
});
1379
1380
- it('should determine the first common ancestor correctly', () => {
1380
+ it('should determine the first common ancestor correctly', async () => {
1381
// This test was moved here from the ReactTreeTraversal test since only the
1382
// ResponderEventPlugin uses `getLowestCommonAncestor`
1383
const React = require('react');
1384
- const ReactTestUtils = require('react-dom/test-utils');
1384
+ const ReactDOMClient = require('react-dom/client');
1385
+ const act = require('internal-test-utils').act;
1386
const getLowestCommonAncestor =
1387
require('react-native-renderer/src/legacy-events/ResponderEventPlugin').getLowestCommonAncestor;
1388
// This works by accident and will likely break in the future.
@@ -1422,7 +1423,12 @@ describe('ResponderEventPlugin', () => {
1423
}
1424
}
1425
1425
- const parent = ReactTestUtils.renderIntoDocument(<ParentComponent />);
1426
+ const container = document.createElement('div');
1427
+ const root = ReactDOMClient.createRoot(container);
1428
+ let parent;
1429
+ await act(() => {
1430
+ root.render(<ParentComponent ref={current => (parent = current)} />);
1431
+ });
1432
1433
const ancestors = [
1434
// Common ancestor with self is self.