Skip to content

Commit

Permalink
Delete test-utils implementation of act (#21703)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
acdlite authored Jun 22, 2021
1 parent 568dc35 commit 422e0bb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 236 deletions.
10 changes: 5 additions & 5 deletions packages/react-dom/src/client/ReactDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import {
flushSync,
flushControlled,
injectIntoDevTools,
flushPassiveEffects,
IsThisRendererActing,
act,
attemptSynchronousHydration,
attemptDiscreteHydration,
attemptContinuousHydration,
Expand Down Expand Up @@ -155,18 +155,18 @@ function renderSubtreeIntoContainer(
}

const Internals = {
// Keep in sync with ReactTestUtils.js, and ReactTestUtilsAct.js.
// Keep in sync with ReactTestUtils.js.
// This is an array for better minification.
Events: [
getInstanceFromNode,
getNodeFromInstance,
getFiberCurrentPropsFromNode,
enqueueStateRestore,
restoreStateIfNeeded,
flushPassiveEffects,
// TODO: This is related to `act`, not events. Move to separate key?
IsThisRendererActing,
],
act,
// TODO: Temporary. Only used by our internal version of `act. Will remove.
IsThisRendererActing,
};

export {
Expand Down
13 changes: 6 additions & 7 deletions packages/react-dom/src/test-utils/ReactTestUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,24 @@ import {
import {SyntheticEvent} from '../events/SyntheticEvent';
import invariant from 'shared/invariant';
import {ELEMENT_NODE} from '../shared/HTMLNodeType';
import {act} from './ReactTestUtilsPublicAct';
import {unstable_concurrentAct} from './ReactTestUtilsInternalAct';
import {
rethrowCaughtError,
invokeGuardedCallbackAndCatchFirstError,
} from 'shared/ReactErrorUtils';
import isArray from 'shared/isArray';

// Keep in sync with ReactDOM.js, and ReactTestUtilsAct.js:
const EventInternals =
ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Events;
// Keep in sync with ReactDOM.js:
const SecretInternals =
ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
const EventInternals = SecretInternals.Events;
const getInstanceFromNode = EventInternals[0];
const getNodeFromInstance = EventInternals[1];
const getFiberCurrentPropsFromNode = EventInternals[2];
const enqueueStateRestore = EventInternals[3];
const restoreStateIfNeeded = EventInternals[4];
// const flushPassiveEffects = EventInternals[5];
// TODO: This is related to `act`, not events. Move to separate key?
// const IsThisRendererActing = EventInternals[6];

const act = SecretInternals.act;

function Event(suffix) {}

Expand Down
13 changes: 3 additions & 10 deletions packages/react-dom/src/test-utils/ReactTestUtilsInternalAct.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,9 @@ import ReactSharedInternals from 'shared/ReactSharedInternals';
import enqueueTask from 'shared/enqueueTask';
import * as Scheduler from 'scheduler';

// Keep in sync with ReactDOM.js, and ReactTestUtils.js:
const EventInternals =
ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Events;
// const getInstanceFromNode = EventInternals[0];
// const getNodeFromInstance = EventInternals[1];
// const getFiberCurrentPropsFromNode = EventInternals[2];
// const enqueueStateRestore = EventInternals[3];
// const restoreStateIfNeeded = EventInternals[4];
// const flushPassiveEffects = EventInternals[5];
const IsThisRendererActing = EventInternals[6];
const SecretInternals =
ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
const IsThisRendererActing = SecretInternals.IsThisRendererActing;

const batchedUpdates = ReactDOM.unstable_batchedUpdates;

Expand Down
214 changes: 0 additions & 214 deletions packages/react-dom/src/test-utils/ReactTestUtilsPublicAct.js

This file was deleted.

0 comments on commit 422e0bb

Please sign in to comment.