From 203177101b34d2e182e1eb11e797696d35f1c982 Mon Sep 17 00:00:00 2001 From: Alem Tuzlak Date: Thu, 20 Jun 2024 11:34:58 +0200 Subject: [PATCH] The one where I expose a return type type --- package.json | 2 +- src/hook/index.tsx | 3 +++ src/testing-app/app/routes/_index.tsx | 8 +++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d80b146..cb71adf 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/hook/index.tsx b/src/hook/index.tsx index 3a0072e..86af44c 100644 --- a/src/hook/index.tsx +++ b/src/hook/index.tsx @@ -197,6 +197,9 @@ export const useRemixForm = ({ return hookReturn; }; + +export type UseRemixFormReturn = ReturnType; + interface RemixFormProviderProps extends Omit, "handleSubmit" | "reset"> { children: React.ReactNode; diff --git a/src/testing-app/app/routes/_index.tsx b/src/testing-app/app/routes/_index.tsx index b305dd2..eb051a2 100644 --- a/src/testing-app/app/routes/_index.tsx +++ b/src/testing-app/app/routes/_index.tsx @@ -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, @@ -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 (

Add a thing...