Skip to content

Commit

Permalink
Move act related stuff out of EventInternals
Browse files Browse the repository at this point in the history
  • Loading branch information
acdlite committed Jun 21, 2021
1 parent a94c8ac commit b5debd5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 23 deletions.
10 changes: 4 additions & 6 deletions packages/react-dom/src/client/ReactDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
flushSync,
flushControlled,
injectIntoDevTools,
flushPassiveEffects,
IsThisRendererActing,
act,
attemptSynchronousHydration,
Expand Down Expand Up @@ -156,19 +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,
],
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 @@ -25,18 +25,17 @@ import {
} 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 = EventInternals[7];

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

0 comments on commit b5debd5

Please sign in to comment.