Skip to content

Commit

Permalink
Deprecate act from react-dom/test-utils in favor of act from `rea…
Browse files Browse the repository at this point in the history
…ct` (#28597)

DiffTrain build for [2b036d3](2b036d3)
  • Loading branch information
eps1lon committed Mar 27, 2024
1 parent b758998 commit 28afafe
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a0537160771bafae90c6fd3154eeead2f2c903e7
2b036d3f1f016fbe8b121d223d96f09e785b97e1
18 changes: 15 additions & 3 deletions compiled/facebook-www/ReactTestUtils-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -921,10 +921,22 @@ if (__DEV__) {
var getNodeFromInstance = EventInternals[1];
var getFiberCurrentPropsFromNode = EventInternals[2];
var enqueueStateRestore = EventInternals[3];
var restoreStateIfNeeded = EventInternals[4]; // TODO: Add a warning if this API is accessed with advice to switch to
// importing directly from the React package instead.
var restoreStateIfNeeded = EventInternals[4];
var didWarnAboutUsingAct = false;

var act = React.act;
function act(callback) {
if (didWarnAboutUsingAct === false) {
didWarnAboutUsingAct = true;

error(
"`ReactDOMTestUtils.act` is deprecated in favor of `React.act`. " +
"Import `act` from `react` instead of `react-dom/test-utils`. " +
"See https://react.dev/warnings/react-dom-test-utils for more info."
);
}

return React.act(callback);
}

function Event(suffix) {}

Expand Down
18 changes: 15 additions & 3 deletions compiled/facebook-www/ReactTestUtils-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -921,10 +921,22 @@ if (__DEV__) {
var getNodeFromInstance = EventInternals[1];
var getFiberCurrentPropsFromNode = EventInternals[2];
var enqueueStateRestore = EventInternals[3];
var restoreStateIfNeeded = EventInternals[4]; // TODO: Add a warning if this API is accessed with advice to switch to
// importing directly from the React package instead.
var restoreStateIfNeeded = EventInternals[4];
var didWarnAboutUsingAct = false;

var act = React.act;
function act(callback) {
if (didWarnAboutUsingAct === false) {
didWarnAboutUsingAct = true;

error(
"`ReactDOMTestUtils.act` is deprecated in favor of `React.act`. " +
"Import `act` from `react` instead of `react-dom/test-utils`. " +
"See https://react.dev/warnings/react-dom-test-utils for more info."
);
}

return React.act(callback);
}

function Event(suffix) {}

Expand Down
1 change: 1 addition & 0 deletions compiled/facebook-www/__test_utils__/ReactAllWarnings.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 28afafe

Please sign in to comment.