[DS-2] Install and integrate React Hook Form #7
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/DS-2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Ticket
DS-2 Install and integrate React Hook Form
Summary
react-hook-form+@hookform/resolversas regular dependencies (not peerDependencies), guaranteeing a single RHF instance across consumers.src/form.tsre-exporting the RHF consumer surface (useForm,FormProvider,useFieldArray,useWatch,zodResolver, plusSubmitHandler/UseFormReturn/Path/RegisterOptionstypes) — consuming apps never installreact-hook-formdirectly.Textas the reference field component (Text.tsxweb /Text.native.tsxnative), wired directly to RHF viauseController/useFormContext— single-layer component, no separateForm*wrapper,rulesprop as an escape hatch alongside schema-first Zod validation.dist/web,dist/native/native, each with its own entry point) plus areact-nativeexportscondition, so Metro-based consumers get the RN build and web bundlers get the DOM build.@testing-library/react,@testing-library/react-native, ahappy-dompreload, areact-nativemock forbun testsince there's no Metro) and shared test utilities (RenderWithForm,renderNative) for this and future field-component tickets.bun run build, gating the dual-target build itself.1. The web field.value ?? "" undefined-guard test asserted on the input's `.value` DOM property, which reads back "" for an uncontrolled input too (i.e. even with the guard removed) -- so it never actually exercised the guard. Assert on the attribute instead (`getAttribute("value")`), which is `null` for an uncontrolled input and only "" once React actually sets a controlled `value` prop. Verified by temporarily removing the guard and confirming the test now fails, then restoring it. 2. tsup's dts output has its own separate clean step (cleanDtsFiles) that always wipes "**/*.d.{ts,mts,cts}" under a config's own outDir and never sees the other config's exclude pattern -- so the prior `clean: ["!native/**"]` fix only ever protected the JS output, not the .d.ts files, from the concurrent-build race. Set `clean: false` on both tsup configs and clean once up front instead, via `rm -rf dist` prefixed onto `package.json`'s `build` and `prepare` scripts (prepare gets the same fix as build since it runs the identical tsup config and faces the same race). Re-verified after both fixes: full `rm -rf dist && bun run build` still produces a dist/index.d.ts and dist/native/index.d.ts that differ correctly (native's Text carries Text.native.tsx's own docstring), all four dist/ and dist/native/ files are present, and bun test/typecheck/lint/build are green.