We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
withCleanup
1 parent 8fcd546 commit 6e36177Copy full SHA for 6e36177
2 files changed
src/profile/disableActWarnings.ts
@@ -1,15 +1,16 @@
1
-import { withCleanup } from "./withCleanup.js";
2
-
3
/**
4
* Temporarily disable act warnings.
5
*
6
* https://github.com/reactwg/react-18/discussions/102
7
*/
8
export function disableActWarnings() {
9
- const prev = { prevActEnv: (globalThis as any).IS_REACT_ACT_ENVIRONMENT };
10
- (globalThis as any).IS_REACT_ACT_ENVIRONMENT = false;
+ const anyThis = globalThis as any;
+ const prevActEnv = anyThis.IS_REACT_ACT_ENVIRONMENT;
+ anyThis.IS_REACT_ACT_ENVIRONMENT = false;
11
12
- return withCleanup(prev, ({ prevActEnv }) => {
13
- (globalThis as any).IS_REACT_ACT_ENVIRONMENT = prevActEnv;
14
- });
+ return {
+ [Symbol.dispose]() {
+ anyThis.IS_REACT_ACT_ENVIRONMENT = prevActEnv;
+ },
15
+ };
16
}
src/profile/withCleanup.ts
0 commit comments