import type {Fiber} from './ReactFiber';
import ReactSharedInternals from 'shared/ReactSharedInternals';
import {warnsIfNotActing} from './ReactFiberHostConfig';
const {ReactCurrentActQueue} = ReactSharedInternals;
export function isLegacyActEnvironment(fiber: Fiber): boolean {
if (__DEV__) {
const isReactActEnvironmentGlobal =
typeof IS_REACT_ACT_ENVIRONMENT !== 'undefined'
?
IS_REACT_ACT_ENVIRONMENT
: undefined;
const jestIsDefined = typeof jest !== 'undefined';
return (
warnsIfNotActing && jestIsDefined && isReactActEnvironmentGlobal !== false
);
}
return false;
}
export function isConcurrentActEnvironment(): void | boolean {
if (__DEV__) {
const isReactActEnvironmentGlobal =
typeof IS_REACT_ACT_ENVIRONMENT !== 'undefined'
?
IS_REACT_ACT_ENVIRONMENT
: undefined;
if (!isReactActEnvironmentGlobal && ReactCurrentActQueue.current !== null) {
console.error(
'The current testing environment is not configured to support ' +
'act(...)',
);
}
return isReactActEnvironmentGlobal;
}
return false;
}