dillon1000/react

Commit

Support disabling spurious act warnings with a global environment flag (#22561)

* Extract `act` environment check into function

`act` checks the environment to determine whether to fire a warning.
We're changing how this check works in React 18. As a first step, this
refactors the logic into a single function. No behavior changes yet.

* Use IS_REACT_ACT_ENVIRONMENT to disable warnings

If `IS_REACT_ACT_ENVIRONMENT` is set to `false`, we will suppress
any `act` warnings. Otherwise, the behavior of `act` is the same as in
React 17: if `jest` is defined, it warns.

In concurrent mode, the plan is to remove the `jest` check and only warn
if `IS_REACT_ACT_ENVIRONMENT` is true. I have not implemented that
part yet.
Browse files
Changed paths16 files
First-parent comparison
M .eslintrc.js ModifiedM packages/jest-react/src/internalAct.js ModifiedM packages/react-dom/src/__tests__/ReactTestUtilsAct-test.js ModifiedA packages/react-reconciler/src/ReactFiberAct.new.js AddedA packages/react-reconciler/src/ReactFiberAct.old.js AddedM packages/react-reconciler/src/ReactFiberHooks.new.js ModifiedM packages/react-reconciler/src/ReactFiberHooks.old.js ModifiedM packages/react-reconciler/src/ReactFiberWorkLoop.new.js ModifiedM packages/react-reconciler/src/ReactFiberWorkLoop.old.js ModifiedM packages/react/src/ReactCurrentActQueue.js ModifiedM scripts/rollup/validate/eslintrc.cjs.js ModifiedM scripts/rollup/validate/eslintrc.cjs2015.js ModifiedM scripts/rollup/validate/eslintrc.esm.js ModifiedM scripts/rollup/validate/eslintrc.fb.js ModifiedM scripts/rollup/validate/eslintrc.rn.js ModifiedM scripts/rollup/validate/eslintrc.umd.js Modified
Patch

Files changed

Rendering syntax-highlighted changes…