diff --git a/compiler/packages/babel-plugin-react-compiler/src/HIR/DefaultModuleTypeProvider.ts b/compiler/packages/babel-plugin-react-compiler/src/HIR/DefaultModuleTypeProvider.ts index 106fce615c4..9c27696396a 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/HIR/DefaultModuleTypeProvider.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/HIR/DefaultModuleTypeProvider.ts @@ -65,6 +65,24 @@ export function defaultModuleTypeProvider( }, }, }, + useFormContext: { + kind: 'hook', + returnType: { + kind: 'object', + properties: { + // Only the `watch()` function returned by react-hook-form's `useFormContext()` API is incompatible + watch: { + kind: 'function', + positionalParams: [], + restParam: Effect.Read, + calleeEffect: Effect.Read, + returnType: {kind: 'type', name: 'Any'}, + returnValueKind: ValueKind.Mutable, + knownIncompatible: `React Hook Form's \`useFormContext()\` API returns a \`watch()\` function which cannot be memoized safely.`, + }, + }, + }, + }, }, }; }