UNPKG

@nexusui/components

Version:

These are custom components specially-developed for NexusUI applications. They will make your life easier by giving you out-of-the-box implementations for various high-level UI elements that you can drop directly into your application.

2 lines (1 loc) 505 B
import{useForm as r}from"react-hook-form";import{useMemo as t,useCallback as o,useEffect as e}from"react";const i=(i,a,n)=>{const{handleSubmit:m,reset:s,control:l,formState:{errors:u,isDirty:d,isValid:h}}=r({defaultValues:t((()=>i),[i]),mode:"onChange"}),c=o((r=>{a(r,{sourceData:n?.currentThumbnail,isChanged:n?.isThumbnailChanged})}),[a,n]),b=t((()=>m(c)),[m,c]);return e((()=>{s(i)}),[i,s]),{handleSubmit:m,isDirty:d,isValid:h,onSubmit:c,control:l,errors:u,handleOnSubmit:b}};export{i as usePartForm};