@samitouri / QOS-React / commits / e3b7ef32be

[crud] Only export uRC when flag is enabled (#31617)

It's tricky to do feature detection of uRC currently because it's always present on the export. Let's conditionally export it instead.

lauren committed Nov 22, 2024 at 16:13 UTC e3b7ef32be6a6d01ea050a10a218538e3a75c64f
2 files changed +9 -1
packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js
+5
@@ -3276,6 +3276,11 @@ describe('ReactHooksWithNoopRenderer', () => {
3276 }
3277 }
3278
3279 + // @gate !enableUseResourceEffectHook
3280 + it('is null when flag is disabled', async () => {
3281 + expect(useResourceEffect).toBeUndefined();
3282 + });
3283 +
3284 // @gate enableUseResourceEffectHook
3285 it('validates create return value', async () => {
3286 function App({id}) {
packages/react/src/ReactClient.js
+4 -1
@@ -65,6 +65,7 @@ import {startTransition} from './ReactStartTransition';
65 import {act} from './ReactAct';
66 import {captureOwnerStack} from './ReactOwnerStack';
67 import ReactCompilerRuntime from './ReactCompilerRuntime';
68 +import {enableUseResourceEffectHook} from 'shared/ReactFeatureFlags';
69
70 const Children = {
71 map,
@@ -90,7 +91,6 @@ export {
91 useContext,
92 useEffect,
93 useEffectEvent as experimental_useEffectEvent,
93 - useResourceEffect as experimental_useResourceEffect,
94 useImperativeHandle,
95 useDebugValue,
96 useInsertionEffect,
@@ -131,3 +131,6 @@ export {
131 act, // DEV-only
132 captureOwnerStack, // DEV-only
133 };
134 +
135 +export const experimental_useResourceEffect: typeof useResourceEffect | void =
136 + enableUseResourceEffectHook ? useResourceEffect : undefined;