Skip to content

Commit 5ec5cce

Browse files
committed
Only affect OSS for now
1 parent b647ea9 commit 5ec5cce

File tree

4 files changed

+30
-82
lines changed

4 files changed

+30
-82
lines changed

packages/react-reconciler/src/__tests__/ReactIsomorphicAct-test.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,16 @@ describe('isomorphic act()', () => {
5050
return text;
5151
}
5252

53-
// @gate !__DEV__
54-
it('is not exported in production builds', () => {
55-
expect(React).not.toHaveProperty('act');
53+
it('behavior in production', () => {
54+
if (!__DEV__) {
55+
if (gate('www')) {
56+
expect(() => act(() => {})).toThrow(
57+
'act(...) is not supported in production builds of React',
58+
);
59+
} else {
60+
expect(React).not.toHaveProperty('act');
61+
}
62+
}
5663
});
5764

5865
// @gate __DEV__

packages/react-reconciler/src/__tests__/ReactOwnerStacks-test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ describe('ReactOwnerStacks', () => {
3131
);
3232
}
3333

34+
it('behavior in production', () => {
35+
if (!__DEV__) {
36+
if (gate('www')) {
37+
expect(React.captureOwnerStack()).toEqual(null);
38+
} else {
39+
expect(React).not.toHaveProperty('act');
40+
}
41+
}
42+
});
3443
it('is not exported in production buids', () => {
3544
// awkward to gate because FB builds will have it undefined if disabled
3645
// whereas OSS builds will have it stripped if disabled because we only have

packages/react/index.fb.development.js

Lines changed: 0 additions & 79 deletions
This file was deleted.

packages/react/index.fb.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
* @flow
88
*/
99

10+
import {enableOwnerStacks} from 'shared/ReactFeatureFlags';
11+
import {captureOwnerStack as captureOwnerStackImpl} from './src/ReactClient';
1012
export {
1113
__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
1214
__COMPILER_RUNTIME,
15+
act,
1316
cache,
1417
Children,
1518
cloneElement,
@@ -67,3 +70,11 @@ export {useMemoCache as unstable_useMemoCache} from './src/ReactHooks';
6770
// export to match the name of the OSS function typically exported from
6871
// react/compiler-runtime
6972
export {useMemoCache as c} from './src/ReactHooks';
73+
74+
// Only export captureOwnerStack in development.
75+
let captureOwnerStack: ?() => null | string;
76+
if (__DEV__ && enableOwnerStacks) {
77+
captureOwnerStack = captureOwnerStackImpl;
78+
}
79+
80+
export {captureOwnerStack};

0 commit comments

Comments
 (0)