Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rhf-7-75-compat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"remix-hook-form": minor
---

Fix type errors with react-hook-form 7.75.0. `FormState` gained an `isReady` field and `UseFormReturn` gained `setValues` in 7.75; the wrapped `formState` now exposes `isReady` (preserving the lazy getter behavior) and `setValues` flows through the hook's return type. Resolves the "Property 'setValues'/'isReady' is missing" errors (#180).
27 changes: 22 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"peerDependencies": {
"react": "^18.2.0 || ^19.0.0",
"react-dom": "^18.2.0 || ^19.0.0",
"react-hook-form": "^7.55.0",
"react-hook-form": "^7.75.0",
"react-router": ">=7.5.0"
},
"readme": "https://github.com/code-forge-io/remix-hook-form#readme",
Expand All @@ -104,7 +104,7 @@
"prettier": "^3.0.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.51.0",
"react-hook-form": "^7.75.0",
"rollup": "^3.20.2",
"rollup-plugin-typescript2": "^0.34.1",
"tsup": "^8.3.5",
Expand Down
11 changes: 9 additions & 2 deletions src/hook/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ describe("useRemixForm", () => {
submitCount: 0,
isLoading: false,
errors: {},
isReady: true,
});
expect(result.current.handleSubmit).toBeInstanceOf(Function);
});
Expand Down Expand Up @@ -217,7 +218,10 @@ describe("useRemixForm", () => {
await new Promise((resolve) => setTimeout(resolve, 0));
});

expect(renderCount()).toBe(1);
// react-hook-form >= 7.75 emits an extra formState notification per
// validation cycle (two cycles here), so the baseline render count is 3.
// The optimization still holds: this stays below the subscribed case below.
expect(renderCount()).toBe(3);
});

it("should re-render on validation if isValidating is being accessed", async () => {
Expand Down Expand Up @@ -255,7 +259,10 @@ describe("useRemixForm", () => {
await new Promise((resolve) => setTimeout(resolve, 0));
});

expect(renderCount()).toBe(3);
// Accessing isValidating subscribes to it, so each validation cycle
// re-renders — 2 more than the unsubscribed case above (3 -> 5 on
// react-hook-form >= 7.75, which raised the baseline by 2).
expect(renderCount()).toBe(5);
});

it("should not flash incorrect isSubmitting status", async () => {
Expand Down
3 changes: 3 additions & 0 deletions src/hook/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ export const useRemixForm = <
get errors() {
return methods.formState.errors;
},
get isReady() {
return methods.formState.isReady;
},
}),
[methods.formState, isSubmittedSuccessfully, isSubmittingNetwork],
);
Expand Down
Loading