Skip to content

Commit

Permalink
The one where I expose a return type type
Browse files Browse the repository at this point in the history
  • Loading branch information
AlemTuzlak committed Jun 20, 2024
1 parent 8fb49c0 commit 2031771
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "remix-hook-form",
"version": "5.0.0",
"version": "5.0.1",
"description": "Utility wrapper around react-hook-form for use with Remix.run",
"type": "module",
"main": "./dist/index.cjs",
Expand Down
3 changes: 3 additions & 0 deletions src/hook/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ export const useRemixForm = <T extends FieldValues>({

return hookReturn;
};

export type UseRemixFormReturn = ReturnType<typeof useRemixForm>;

interface RemixFormProviderProps<T extends FieldValues>
extends Omit<UseFormReturn<T>, "handleSubmit" | "reset"> {
children: React.ReactNode;
Expand Down
8 changes: 7 additions & 1 deletion src/testing-app/app/routes/_index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
type UploadHandler,
} from "@remix-run/node";
import { Form, useFetcher } from "@remix-run/react";
import { useEffect } from "react";
import {
getValidatedFormData,
useRemixForm,
Expand Down Expand Up @@ -95,7 +96,12 @@ export default function Index() {
},
});
const { register, handleSubmit, formState, watch, setError } = methods;

useEffect(() => {
setError("root.file", {
message: "File is required",
});
}, []);
console.log(formState.errors);
return (
<RemixFormProvider {...methods}>
<p>Add a thing...</p>
Expand Down

0 comments on commit 2031771

Please sign in to comment.