[compiler] Add useFormContext to known incompatible libraries#306
[compiler] Add useFormContext to known incompatible libraries#306everettbu wants to merge 2 commits into
Conversation
The original implementation in #34027 added useForm from react-hook-form to the known incompatible libraries list, but missed useFormContext. useFormContext returns the same API surface as useForm, including the watch() function that cannot be memoized safely. This PR adds useFormContext with the same configuration as useForm I repurposed @Maxou44 's original repro repo from #11910 to demonstrate that the issue can be reproduced with useFormContext too, you can play around with the updated demo if you want to confirm, repo link below https://github.com/reyronald/issue-react-compiler-react-hook-form
There was a problem hiding this comment.
Greptile Overview
Greptile Summary
This PR correctly adds useFormContext to the list of known incompatible React Hook Form APIs. The implementation mirrors the existing useForm configuration, marking only the watch() function as incompatible with memoization.
Key Changes:
- Added
useFormContexthook configuration with identical structure touseForm - Properly marked the
watch()function withValueKind.MutableandknownIncompatiblemessage - Used consistent configuration:
Effect.ReadforrestParamandcalleeEffect, matching the existing pattern
The change is minimal, focused, and correctly addresses the gap identified in the original implementation. Since useFormContext returns the same API surface as useForm (including the problematic watch() function), this addition is necessary for complete coverage.
Confidence Score: 5/5
- This PR is safe to merge with no identified issues
- The change is a straightforward addition that perfectly follows the established pattern. The configuration is identical to the existing
useFormsetup, correctly addresses a documented gap, and includes no logical errors or inconsistencies. The implementation is well-documented with inline comments explaining the incompatibility. - No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| compiler/packages/babel-plugin-react-compiler/src/HIR/DefaultModuleTypeProvider.ts | 5/5 | Added useFormContext hook configuration identical to useForm, correctly marking the watch() function as incompatible with memoization |
Greptile SummaryThis PR adds Changes:
Notes:
Confidence Score: 5/5
Important Files Changed
Last reviewed commit: c0951ba |
Mirror of facebook/react#35465
Original author: reyronald
The original implementation in #34027 added useForm from react-hook-form to the known incompatible libraries list, but missed useFormContext. useFormContext returns the same API surface as useForm, including the watch() function that cannot be memoized safely.
This PR adds useFormContext with the same configuration as useForm
I repurposed
@Maxou44's original repro repo from react-hook-form/react-hook-form#11910 to demonstrate that the issue can be reproduced with useFormContext too, you can play around with the updated demo if you want to confirm, repo link belowhttps://github.com/reyronald/issue-react-compiler-react-hook-form
Repro details
References