Skip to content

Commit f367053

Browse files
fix: reference dev-only act with computed key for Webpack (#3513)
1 parent 2ca6f77 commit f367053

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

packages/fiber/src/core/utils.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,11 @@ export type Act = <T = any>(cb: () => Promise<T>) => Promise<T>
3030

3131
/**
3232
* Safely flush async effects when testing, simulating a legacy root.
33+
* @deprecated Import from React instead. import { act } from 'react'
3334
*/
34-
export const act: Act = (cb) => {
35-
if ('act' in React) {
36-
return React.act(cb)
37-
}
38-
39-
throw new Error('act(...) is not supported in production builds of React')
40-
}
35+
// Reference with computed key to break Webpack static analysis
36+
// https://github.com/webpack/webpack/issues/14814
37+
export const act: Act = React[('act' + '') as 'act']
4138

4239
export type Camera = (THREE.OrthographicCamera | THREE.PerspectiveCamera) & { manual?: boolean }
4340
export const isOrthographicCamera = (def: Camera): def is THREE.OrthographicCamera =>

0 commit comments

Comments
 (0)