Created
February 1, 2023 03:21
-
-
Save vinnymac/00878aaa1646f08b8c9d06ef21defc34 to your computer and use it in GitHub Desktop.
React 18 Act Environment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getGlobalThis() { | |
return global || globalThis || self || window; | |
} | |
export function disableReactActEnv() { | |
let prev: boolean; | |
beforeEach(() => { | |
prev = getGlobalThis().IS_REACT_ACT_ENVIRONMENT; | |
getGlobalThis().IS_REACT_ACT_ENVIRONMENT = false; | |
}); | |
afterEach(() => { | |
getGlobalThis().IS_REACT_ACT_ENVIRONMENT = prev; | |
}); | |
} | |
export function enableReactActEnv() { | |
let prev: boolean; | |
beforeEach(() => { | |
prev = getGlobalThis().IS_REACT_ACT_ENVIRONMENT; | |
getGlobalThis().IS_REACT_ACT_ENVIRONMENT = true; | |
}); | |
afterEach(() => { | |
getGlobalThis().IS_REACT_ACT_ENVIRONMENT = prev; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment