mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
01bb3c5632
We landed a flag to disable test utils in many builds but we need to fork the entrypoint to make it work with tests properly. This also removes test-utils implementations from builds that do not support it. Currently in OSS builds the only thing in test-utils is a reexport of `act`
24 lines
666 B
JavaScript
24 lines
666 B
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @noflow
|
|
*/
|
|
|
|
import * as React from 'react';
|
|
|
|
let didWarnAboutUsingAct = false;
|
|
export function act(callback) {
|
|
if (didWarnAboutUsingAct === false) {
|
|
didWarnAboutUsingAct = true;
|
|
console.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);
|
|
}
|