Skip to content

Commit 422e0bb

Browse files
authored
Delete test-utils implementation of act (#21703)
* Delete test-utils implementation of `act` Since it's dev-only now, we can use the one provided by the reconciler. * Move act related stuff out of EventInternals
1 parent 568dc35 commit 422e0bb

File tree

4 files changed

+14
-236
lines changed

4 files changed

+14
-236
lines changed

packages/react-dom/src/client/ReactDOM.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ import {
2828
flushSync,
2929
flushControlled,
3030
injectIntoDevTools,
31-
flushPassiveEffects,
3231
IsThisRendererActing,
32+
act,
3333
attemptSynchronousHydration,
3434
attemptDiscreteHydration,
3535
attemptContinuousHydration,
@@ -155,18 +155,18 @@ function renderSubtreeIntoContainer(
155155
}
156156

157157
const Internals = {
158-
// Keep in sync with ReactTestUtils.js, and ReactTestUtilsAct.js.
158+
// Keep in sync with ReactTestUtils.js.
159159
// This is an array for better minification.
160160
Events: [
161161
getInstanceFromNode,
162162
getNodeFromInstance,
163163
getFiberCurrentPropsFromNode,
164164
enqueueStateRestore,
165165
restoreStateIfNeeded,
166-
flushPassiveEffects,
167-
// TODO: This is related to `act`, not events. Move to separate key?
168-
IsThisRendererActing,
169166
],
167+
act,
168+
// TODO: Temporary. Only used by our internal version of `act. Will remove.
169+
IsThisRendererActing,
170170
};
171171

172172
export {

packages/react-dom/src/test-utils/ReactTestUtils.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,24 @@ import {
1818
import {SyntheticEvent} from '../events/SyntheticEvent';
1919
import invariant from 'shared/invariant';
2020
import {ELEMENT_NODE} from '../shared/HTMLNodeType';
21-
import {act} from './ReactTestUtilsPublicAct';
2221
import {unstable_concurrentAct} from './ReactTestUtilsInternalAct';
2322
import {
2423
rethrowCaughtError,
2524
invokeGuardedCallbackAndCatchFirstError,
2625
} from 'shared/ReactErrorUtils';
2726
import isArray from 'shared/isArray';
2827

29-
// Keep in sync with ReactDOM.js, and ReactTestUtilsAct.js:
30-
const EventInternals =
31-
ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Events;
28+
// Keep in sync with ReactDOM.js:
29+
const SecretInternals =
30+
ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
31+
const EventInternals = SecretInternals.Events;
3232
const getInstanceFromNode = EventInternals[0];
3333
const getNodeFromInstance = EventInternals[1];
3434
const getFiberCurrentPropsFromNode = EventInternals[2];
3535
const enqueueStateRestore = EventInternals[3];
3636
const restoreStateIfNeeded = EventInternals[4];
37-
// const flushPassiveEffects = EventInternals[5];
38-
// TODO: This is related to `act`, not events. Move to separate key?
39-
// const IsThisRendererActing = EventInternals[6];
37+
38+
const act = SecretInternals.act;
4039

4140
function Event(suffix) {}
4241

packages/react-dom/src/test-utils/ReactTestUtilsInternalAct.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,9 @@ import ReactSharedInternals from 'shared/ReactSharedInternals';
1414
import enqueueTask from 'shared/enqueueTask';
1515
import * as Scheduler from 'scheduler';
1616

17-
// Keep in sync with ReactDOM.js, and ReactTestUtils.js:
18-
const EventInternals =
19-
ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Events;
20-
// const getInstanceFromNode = EventInternals[0];
21-
// const getNodeFromInstance = EventInternals[1];
22-
// const getFiberCurrentPropsFromNode = EventInternals[2];
23-
// const enqueueStateRestore = EventInternals[3];
24-
// const restoreStateIfNeeded = EventInternals[4];
25-
// const flushPassiveEffects = EventInternals[5];
26-
const IsThisRendererActing = EventInternals[6];
17+
const SecretInternals =
18+
ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
19+
const IsThisRendererActing = SecretInternals.IsThisRendererActing;
2720

2821
const batchedUpdates = ReactDOM.unstable_batchedUpdates;
2922

packages/react-dom/src/test-utils/ReactTestUtilsPublicAct.js

Lines changed: 0 additions & 214 deletions
This file was deleted.

0 commit comments

Comments
 (0)