Skip to content

Commit

Permalink
[crud] Only export uRC when flag is enabled (#31617)
Browse files Browse the repository at this point in the history
It's tricky to do feature detection of uRC currently because it's always
present on the export. Let's conditionally export it instead.
  • Loading branch information
poteto authored Nov 22, 2024
1 parent eee5ca2 commit e3b7ef3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3276,6 +3276,11 @@ describe('ReactHooksWithNoopRenderer', () => {
}
}

// @gate !enableUseResourceEffectHook
it('is null when flag is disabled', async () => {
expect(useResourceEffect).toBeUndefined();
});

// @gate enableUseResourceEffectHook
it('validates create return value', async () => {
function App({id}) {
Expand Down
5 changes: 4 additions & 1 deletion packages/react/src/ReactClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import {startTransition} from './ReactStartTransition';
import {act} from './ReactAct';
import {captureOwnerStack} from './ReactOwnerStack';
import ReactCompilerRuntime from './ReactCompilerRuntime';
import {enableUseResourceEffectHook} from 'shared/ReactFeatureFlags';

const Children = {
map,
Expand All @@ -90,7 +91,6 @@ export {
useContext,
useEffect,
useEffectEvent as experimental_useEffectEvent,
useResourceEffect as experimental_useResourceEffect,
useImperativeHandle,
useDebugValue,
useInsertionEffect,
Expand Down Expand Up @@ -131,3 +131,6 @@ export {
act, // DEV-only
captureOwnerStack, // DEV-only
};

export const experimental_useResourceEffect: typeof useResourceEffect | void =
enableUseResourceEffectHook ? useResourceEffect : undefined;

0 comments on commit e3b7ef3

Please sign in to comment.