GeezerVison is showing github.com — Decouple public, internal act implementation (#19745) · react/react@d17086c
File treeExpand file treeCollapse file tree Open diff view settings react-debug-tools/src/__tests__ react-devtools-shared/src/__tests__ react-interactions/events/src/dom/create-event-handle/__tests__ react-refresh/src/__tests__ react-transport-dom-relay/src/__tests__ react-transport-dom-webpack/src/__tests__ use-subscription/src/__tests__
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/react-debug-tools/src/__tests__/ReactHooksInspectionIntegration-test.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -22,7 +22,7 @@ describe('ReactHooksInspectionIntegration', () => { | 22 | 22 | React = require('react'); | 23 | 23 | ReactTestRenderer = require('react-test-renderer'); | 24 | 24 | Scheduler = require('scheduler'); | 25 | | - act = ReactTestRenderer.act; | | 25 | + act = ReactTestRenderer.unstable_concurrentAct; | 26 | 26 | ReactDebugTools = require('react-debug-tools'); | 27 | 27 | }); | 28 | 28 |
| |
Collapse file Copy file name to clipboardExpand all lines: packages/react-devtools-shared/src/__tests__/inspectedElementContext-test.js +25-20Lines changed: 25 additions & 20 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -33,6 +33,9 @@ describe('InspectedElementContext', () => { | 33 | 33 | let TestUtils; | 34 | 34 | let TreeContextController; | 35 | 35 |
| | 36 | + let TestUtilsAct; | | 37 | + let TestRendererAct; | | 38 | + | 36 | 39 | beforeEach(() => { | 37 | 40 | utils = require('./utils'); | 38 | 41 | utils.beforeEachProfiling(); | @@ -47,7 +50,9 @@ describe('InspectedElementContext', () => { | 47 | 50 | ReactDOM = require('react-dom'); | 48 | 51 | PropTypes = require('prop-types'); | 49 | 52 | TestUtils = require('react-dom/test-utils'); | | 53 | + TestUtilsAct = TestUtils.unstable_concurrentAct; | 50 | 54 | TestRenderer = utils.requireTestRenderer(); | | 55 | + TestRendererAct = TestUtils.unstable_concurrentAct; | 51 | 56 |
| 52 | 57 | BridgeContext = require('react-devtools-shared/src/devtools/views/context') | 53 | 58 | .BridgeContext; | @@ -999,8 +1004,8 @@ describe('InspectedElementContext', () => { | 999 | 1004 | expect(inspectedElement).toMatchSnapshot('1: Initially inspect element'); | 1000 | 1005 |
| 1001 | 1006 | inspectedElement = null; | 1002 | | - TestUtils.act(() => { | 1003 | | - TestRenderer.act(() => { | | 1007 | + TestUtilsAct(() => { | | 1008 | + TestRendererAct(() => { | 1004 | 1009 | getInspectedElementPath(id, ['props', 'nestedObject', 'a']); | 1005 | 1010 | jest.runOnlyPendingTimers(); | 1006 | 1011 | }); | @@ -1009,8 +1014,8 @@ describe('InspectedElementContext', () => { | 1009 | 1014 | expect(inspectedElement).toMatchSnapshot('2: Inspect props.nestedObject.a'); | 1010 | 1015 |
| 1011 | 1016 | inspectedElement = null; | 1012 | | - TestUtils.act(() => { | 1013 | | - TestRenderer.act(() => { | | 1017 | + TestUtilsAct(() => { | | 1018 | + TestRendererAct(() => { | 1014 | 1019 | getInspectedElementPath(id, ['props', 'nestedObject', 'a', 'b', 'c']); | 1015 | 1020 | jest.runOnlyPendingTimers(); | 1016 | 1021 | }); | @@ -1021,8 +1026,8 @@ describe('InspectedElementContext', () => { | 1021 | 1026 | ); | 1022 | 1027 |
| 1023 | 1028 | inspectedElement = null; | 1024 | | - TestUtils.act(() => { | 1025 | | - TestRenderer.act(() => { | | 1029 | + TestUtilsAct(() => { | | 1030 | + TestRendererAct(() => { | 1026 | 1031 | getInspectedElementPath(id, [ | 1027 | 1032 | 'props', | 1028 | 1033 | 'nestedObject', | @@ -1041,8 +1046,8 @@ describe('InspectedElementContext', () => { | 1041 | 1046 | ); | 1042 | 1047 |
| 1043 | 1048 | inspectedElement = null; | 1044 | | - TestUtils.act(() => { | 1045 | | - TestRenderer.act(() => { | | 1049 | + TestUtilsAct(() => { | | 1050 | + TestRendererAct(() => { | 1046 | 1051 | getInspectedElementPath(id, ['hooks', 0, 'value']); | 1047 | 1052 | jest.runOnlyPendingTimers(); | 1048 | 1053 | }); | @@ -1051,8 +1056,8 @@ describe('InspectedElementContext', () => { | 1051 | 1056 | expect(inspectedElement).toMatchSnapshot('5: Inspect hooks.0.value'); | 1052 | 1057 |
| 1053 | 1058 | inspectedElement = null; | 1054 | | - TestUtils.act(() => { | 1055 | | - TestRenderer.act(() => { | | 1059 | + TestUtilsAct(() => { | | 1060 | + TestRendererAct(() => { | 1056 | 1061 | getInspectedElementPath(id, ['hooks', 0, 'value', 'foo', 'bar']); | 1057 | 1062 | jest.runOnlyPendingTimers(); | 1058 | 1063 | }); | @@ -1108,8 +1113,8 @@ describe('InspectedElementContext', () => { | 1108 | 1113 | expect(inspectedElement).toMatchSnapshot('1: Initially inspect element'); | 1109 | 1114 |
| 1110 | 1115 | inspectedElement = null; | 1111 | | - TestUtils.act(() => { | 1112 | | - TestRenderer.act(() => { | | 1116 | + TestUtilsAct(() => { | | 1117 | + TestRendererAct(() => { | 1113 | 1118 | getInspectedElementPath(id, ['props', 'set_of_sets', 0]); | 1114 | 1119 | jest.runOnlyPendingTimers(); | 1115 | 1120 | }); | @@ -1179,23 +1184,23 @@ describe('InspectedElementContext', () => { | 1179 | 1184 | expect(inspectedElement).toMatchSnapshot('1: Initially inspect element'); | 1180 | 1185 |
| 1181 | 1186 | inspectedElement = null; | 1182 | | - TestRenderer.act(() => { | | 1187 | + TestRendererAct(() => { | 1183 | 1188 | getInspectedElementPath(id, ['props', 'nestedObject', 'a']); | 1184 | 1189 | jest.runOnlyPendingTimers(); | 1185 | 1190 | }); | 1186 | 1191 | expect(inspectedElement).not.toBeNull(); | 1187 | 1192 | expect(inspectedElement).toMatchSnapshot('2: Inspect props.nestedObject.a'); | 1188 | 1193 |
| 1189 | 1194 | inspectedElement = null; | 1190 | | - TestRenderer.act(() => { | | 1195 | + TestRendererAct(() => { | 1191 | 1196 | getInspectedElementPath(id, ['props', 'nestedObject', 'c']); | 1192 | 1197 | jest.runOnlyPendingTimers(); | 1193 | 1198 | }); | 1194 | 1199 | expect(inspectedElement).not.toBeNull(); | 1195 | 1200 | expect(inspectedElement).toMatchSnapshot('3: Inspect props.nestedObject.c'); | 1196 | 1201 |
| 1197 | | - TestRenderer.act(() => { | 1198 | | - TestUtils.act(() => { | | 1202 | + TestRendererAct(() => { | | 1203 | + TestUtilsAct(() => { | 1199 | 1204 | ReactDOM.render( | 1200 | 1205 | <Example | 1201 | 1206 | nestedObject={{ | @@ -1221,7 +1226,7 @@ describe('InspectedElementContext', () => { | 1221 | 1226 | }); | 1222 | 1227 | }); | 1223 | 1228 |
| 1224 | | - TestRenderer.act(() => { | | 1229 | + TestRendererAct(() => { | 1225 | 1230 | inspectedElement = null; | 1226 | 1231 | jest.advanceTimersByTime(1000); | 1227 | 1232 | }); | @@ -1281,7 +1286,7 @@ describe('InspectedElementContext', () => { | 1281 | 1286 | expect(inspectedElement).not.toBeNull(); | 1282 | 1287 | expect(inspectedElement).toMatchSnapshot('1: Initially inspect element'); | 1283 | 1288 |
| 1284 | | - TestUtils.act(() => { | | 1289 | + TestUtilsAct(() => { | 1285 | 1290 | ReactDOM.render( | 1286 | 1291 | <Example | 1287 | 1292 | nestedObject={{ | @@ -1300,8 +1305,8 @@ describe('InspectedElementContext', () => { | 1300 | 1305 |
| 1301 | 1306 | inspectedElement = null; | 1302 | 1307 |
| 1303 | | - TestRenderer.act(() => { | 1304 | | - TestUtils.act(() => { | | 1308 | + TestRendererAct(() => { | | 1309 | + TestUtilsAct(() => { | 1305 | 1310 | getInspectedElementPath(id, ['props', 'nestedObject', 'a']); | 1306 | 1311 | jest.runOnlyPendingTimers(); | 1307 | 1312 | }); | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-devtools-shared/src/__tests__/storeComponentFilters-test.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -20,7 +20,7 @@ describe('Store component filters', () => { | 20 | 20 | let utils; | 21 | 21 |
| 22 | 22 | const act = (callback: Function) => { | 23 | | - TestUtils.act(() => { | | 23 | + TestUtils.unstable_concurrentAct(() => { | 24 | 24 | callback(); | 25 | 25 | }); | 26 | 26 | jest.runAllTimers(); // Flush Bridge operations | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/__tests__/ReactDOMFiberAsync-test.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -28,7 +28,7 @@ describe('ReactDOMFiberAsync', () => { | 28 | 28 | container = document.createElement('div'); | 29 | 29 | React = require('react'); | 30 | 30 | ReactDOM = require('react-dom'); | 31 | | - act = require('react-dom/test-utils').act; | | 31 | + act = require('react-dom/test-utils').unstable_concurrentAct; | 32 | 32 | Scheduler = require('scheduler'); | 33 | 33 |
| 34 | 34 | document.body.appendChild(container); | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/__tests__/ReactDOMServerIntegrationHooks-test.js +15-13Lines changed: 15 additions & 13 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -17,6 +17,7 @@ let React; | 17 | 17 | let ReactDOM; | 18 | 18 | let ReactDOMServer; | 19 | 19 | let ReactTestUtils; | | 20 | +let act; | 20 | 21 | let Scheduler; | 21 | 22 | let useState; | 22 | 23 | let useReducer; | @@ -43,6 +44,7 @@ function initModules() { | 43 | 44 | ReactDOMServer = require('react-dom/server'); | 44 | 45 | ReactTestUtils = require('react-dom/test-utils'); | 45 | 46 | Scheduler = require('scheduler'); | | 47 | + act = ReactTestUtils.unstable_concurrentAct; | 46 | 48 | useState = React.useState; | 47 | 49 | useReducer = React.useReducer; | 48 | 50 | useEffect = React.useEffect; | @@ -1063,7 +1065,7 @@ describe('ReactDOMServerHooks', () => { | 1063 | 1065 | expect(domNode.children.length).toEqual(1); | 1064 | 1066 | expect(oldClientId).not.toBeNull(); | 1065 | 1067 |
| 1066 | | - await ReactTestUtils.act(async () => _setShowId(true)); | | 1068 | + await act(async () => _setShowId(true)); | 1067 | 1069 |
| 1068 | 1070 | expect(domNode.children.length).toEqual(2); | 1069 | 1071 | expect(domNode.children[0].getAttribute('aria-labelledby')).toEqual( | @@ -1281,7 +1283,7 @@ describe('ReactDOMServerHooks', () => { | 1281 | 1283 | const oldServerId = container.children[0].children[0].getAttribute('id'); | 1282 | 1284 | expect(oldServerId).not.toBeNull(); | 1283 | 1285 |
| 1284 | | - await ReactTestUtils.act(async () => { | | 1286 | + await act(async () => { | 1285 | 1287 | _setShowDiv(true); | 1286 | 1288 | }); | 1287 | 1289 | expect(container.children[0].children.length).toEqual(2); | @@ -1322,7 +1324,7 @@ describe('ReactDOMServerHooks', () => { | 1322 | 1324 | const oldServerId = container.children[0].children[0].getAttribute('id'); | 1323 | 1325 | expect(oldServerId).not.toBeNull(); | 1324 | 1326 |
| 1325 | | - await ReactTestUtils.act(async () => { | | 1327 | + await act(async () => { | 1326 | 1328 | _setShowDiv(true); | 1327 | 1329 | }); | 1328 | 1330 | expect(container.children[0].children.length).toEqual(2); | @@ -1356,12 +1358,12 @@ describe('ReactDOMServerHooks', () => { | 1356 | 1358 | document.body.append(container); | 1357 | 1359 | container.innerHTML = ReactDOMServer.renderToString(<App />); | 1358 | 1360 | const root = ReactDOM.unstable_createRoot(container, {hydrate: true}); | 1359 | | - ReactTestUtils.act(() => { | | 1361 | + act(() => { | 1360 | 1362 | root.render(<App />); | 1361 | 1363 | }); | 1362 | 1364 | expect(Scheduler).toHaveYielded(['App', 'App']); | 1363 | 1365 | // The ID goes from not being used to being added to the page | 1364 | | - ReactTestUtils.act(() => { | | 1366 | + act(() => { | 1365 | 1367 | _setShow(true); | 1366 | 1368 | }); | 1367 | 1369 | expect(Scheduler).toHaveYielded(['App', 'App']); | @@ -1391,7 +1393,7 @@ describe('ReactDOMServerHooks', () => { | 1391 | 1393 | ReactDOM.hydrate(<App />, container); | 1392 | 1394 | expect(Scheduler).toHaveYielded(['App', 'App']); | 1393 | 1395 | // The ID goes from not being used to being added to the page | 1394 | | - ReactTestUtils.act(() => { | | 1396 | + act(() => { | 1395 | 1397 | _setShow(true); | 1396 | 1398 | }); | 1397 | 1399 | expect(Scheduler).toHaveYielded(['App']); | @@ -1418,12 +1420,12 @@ describe('ReactDOMServerHooks', () => { | 1418 | 1420 | document.body.append(container); | 1419 | 1421 | container.innerHTML = ReactDOMServer.renderToString(<App />); | 1420 | 1422 | const root = ReactDOM.unstable_createRoot(container, {hydrate: true}); | 1421 | | - ReactTestUtils.act(() => { | | 1423 | + act(() => { | 1422 | 1424 | root.render(<App />); | 1423 | 1425 | }); | 1424 | 1426 |
| 1425 | 1427 | // The ID goes from not being used to being added to the page | 1426 | | - ReactTestUtils.act(() => { | | 1428 | + act(() => { | 1427 | 1429 | ReactDOM.flushSync(() => { | 1428 | 1430 | _setShow(true); | 1429 | 1431 | }); | @@ -1518,7 +1520,7 @@ describe('ReactDOMServerHooks', () => { | 1518 | 1520 | expect(child1Ref.current).toBe(null); | 1519 | 1521 | expect(Scheduler).toHaveYielded([]); | 1520 | 1522 |
| 1521 | | - ReactTestUtils.act(() => { | | 1523 | + act(() => { | 1522 | 1524 | _setShow(true); | 1523 | 1525 |
| 1524 | 1526 | // State update should trigger the ID to update, which changes the props | @@ -1603,7 +1605,7 @@ describe('ReactDOMServerHooks', () => { | 1603 | 1605 |
| 1604 | 1606 | suspend = true; | 1605 | 1607 | const root = ReactDOM.unstable_createRoot(container, {hydrate: true}); | 1606 | | - await ReactTestUtils.act(async () => { | | 1608 | + await act(async () => { | 1607 | 1609 | root.render(<App />); | 1608 | 1610 | }); | 1609 | 1611 | jest.runAllTimers(); | @@ -1616,7 +1618,7 @@ describe('ReactDOMServerHooks', () => { | 1616 | 1618 | container.children[0].children[0].getAttribute('id'), | 1617 | 1619 | ).not.toBeNull(); | 1618 | 1620 |
| 1619 | | - await ReactTestUtils.act(async () => { | | 1621 | + await act(async () => { | 1620 | 1622 | suspend = false; | 1621 | 1623 | resolve(); | 1622 | 1624 | await promise; | @@ -1703,7 +1705,7 @@ describe('ReactDOMServerHooks', () => { | 1703 | 1705 |
| 1704 | 1706 | suspend = false; | 1705 | 1707 | const root = ReactDOM.unstable_createRoot(container, {hydrate: true}); | 1706 | | - await ReactTestUtils.act(async () => { | | 1708 | + await act(async () => { | 1707 | 1709 | root.render(<App />); | 1708 | 1710 | }); | 1709 | 1711 | jest.runAllTimers(); | @@ -1968,7 +1970,7 @@ describe('ReactDOMServerHooks', () => { | 1968 | 1970 | expect(Scheduler).toHaveYielded([]); | 1969 | 1971 | expect(Scheduler).toFlushAndYield([]); | 1970 | 1972 |
| 1971 | | - ReactTestUtils.act(() => { | | 1973 | + act(() => { | 1972 | 1974 | _setShow(false); | 1973 | 1975 | }); | 1974 | 1976 |
| |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -79,7 +79,7 @@ describe('ReactDOMServerPartialHydration', () => { | 79 | 79 |
| 80 | 80 | React = require('react'); | 81 | 81 | ReactDOM = require('react-dom'); | 82 | | - act = require('react-dom/test-utils').act; | | 82 | + act = require('react-dom/test-utils').unstable_concurrentAct; | 83 | 83 | ReactDOMServer = require('react-dom/server'); | 84 | 84 | Scheduler = require('scheduler'); | 85 | 85 | Suspense = React.Suspense; | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/__tests__/ReactDOMServerSelectiveHydration-test.internal.js +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -17,6 +17,7 @@ let ReactDOMServer; | 17 | 17 | let ReactTestUtils; | 18 | 18 | let Scheduler; | 19 | 19 | let Suspense; | | 20 | +let act; | 20 | 21 |
| 21 | 22 | function dispatchMouseHoverEvent(to, from) { | 22 | 23 | if (!to) { | @@ -101,6 +102,7 @@ describe('ReactDOMServerSelectiveHydration', () => { | 101 | 102 | ReactDOM = require('react-dom'); | 102 | 103 | ReactDOMServer = require('react-dom/server'); | 103 | 104 | ReactTestUtils = require('react-dom/test-utils'); | | 105 | + act = ReactTestUtils.unstable_concurrentAct; | 104 | 106 | Scheduler = require('scheduler'); | 105 | 107 | Suspense = React.Suspense; | 106 | 108 | }); | @@ -880,7 +882,7 @@ describe('ReactDOMServerSelectiveHydration', () => { | 880 | 882 | const spanC = container.getElementsByTagName('span')[4]; | 881 | 883 |
| 882 | 884 | const root = ReactDOM.createRoot(container, {hydrate: true}); | 883 | | - ReactTestUtils.act(() => { | | 885 | + act(() => { | 884 | 886 | root.render(<App a="A" />); | 885 | 887 |
| 886 | 888 | // Hydrate the shell. | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/__tests__/ReactDOMServerSuspense-test.internal.js +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -15,6 +15,7 @@ let React; | 15 | 15 | let ReactDOM; | 16 | 16 | let ReactDOMServer; | 17 | 17 | let ReactTestUtils; | | 18 | +let act; | 18 | 19 |
| 19 | 20 | function initModules() { | 20 | 21 | // Reset warning cache. | @@ -24,6 +25,7 @@ function initModules() { | 24 | 25 | ReactDOM = require('react-dom'); | 25 | 26 | ReactDOMServer = require('react-dom/server'); | 26 | 27 | ReactTestUtils = require('react-dom/test-utils'); | | 28 | + act = ReactTestUtils.unstable_concurrentAct; | 27 | 29 |
| 28 | 30 | // Make them available to the helpers. | 29 | 31 | return { | @@ -124,7 +126,7 @@ describe('ReactDOMServerSuspense', () => { | 124 | 126 | expect(divB.tagName).toBe('DIV'); | 125 | 127 | expect(divB.textContent).toBe('B'); | 126 | 128 |
| 127 | | - ReactTestUtils.act(() => { | | 129 | + act(() => { | 128 | 130 | const root = ReactDOM.createBlockingRoot(parent, {hydrate: true}); | 129 | 131 | root.render(example); | 130 | 132 | }); | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/__tests__/ReactDOMSuspensePlaceholder-test.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -28,7 +28,7 @@ describe('ReactDOMSuspensePlaceholder', () => { | 28 | 28 | ReactCache = require('react-cache'); | 29 | 29 | ReactTestUtils = require('react-dom/test-utils'); | 30 | 30 | Scheduler = require('scheduler'); | 31 | | - act = ReactTestUtils.act; | | 31 | + act = ReactTestUtils.unstable_concurrentAct; | 32 | 32 | Suspense = React.Suspense; | 33 | 33 | container = document.createElement('div'); | 34 | 34 | document.body.appendChild(container); | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/__tests__/ReactErrorBoundaries-test.internal.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -44,7 +44,7 @@ describe('ReactErrorBoundaries', () => { | 44 | 44 | ReactFeatureFlags.replayFailedUnitOfWorkWithInvokeGuardedCallback = false; | 45 | 45 | ReactDOM = require('react-dom'); | 46 | 46 | React = require('react'); | 47 | | - act = require('react-dom/test-utils').act; | | 47 | + act = require('react-dom/test-utils').unstable_concurrentAct; | 48 | 48 | Scheduler = require('scheduler'); | 49 | 49 |
| 50 | 50 | BrokenConstructor = class extends React.Component { | |
|