From 7dd66e4aeb332202b192e09e1a6032cb7fc78e86 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Fri, 2 Feb 2024 00:53:25 +0100 Subject: [PATCH] Convert ResponderEventPlugin to createRoot (#28190) --- .../__tests__/ResponderEventPlugin-test.internal.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/react-native-renderer/src/__tests__/ResponderEventPlugin-test.internal.js b/packages/react-native-renderer/src/__tests__/ResponderEventPlugin-test.internal.js index 98328bc435af9..ccd84d08a0d5d 100644 --- a/packages/react-native-renderer/src/__tests__/ResponderEventPlugin-test.internal.js +++ b/packages/react-native-renderer/src/__tests__/ResponderEventPlugin-test.internal.js @@ -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. @@ -1422,7 +1423,12 @@ describe('ResponderEventPlugin', () => { } } - const parent = ReactTestUtils.renderIntoDocument(); + const container = document.createElement('div'); + const root = ReactDOMClient.createRoot(container); + let parent; + await act(() => { + root.render( (parent = current)} />); + }); const ancestors = [ // Common ancestor with self is self.