You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Next Levelimport{createForm,requiredValidator,emailValidator}from"solform";functionApp(){const{ register, submit, errors }=createForm<{email: string;count: number;}>({validators: {count: requiredValidator("Count is required"),email: [requiredValidator("This field is required"),emailValidator("Value should be email!"),],},onSubmit: (values)=>{// type safe valuesconsole.log(values);},});return(<div><input{...register("email")}type="email"/>{errors.email&&<pclass="error">{errors.email}</p>}{/* When you read count, it will be converted to number */}<input{...register("count")}type="number"/><buttononClick={submit}>Submit</button></div>);}
// Fullimport{createForm,requiredValidator,emailValidator}from"solform";functionApp(){const{ register, submit, loading, getAllValues, getValue, setValue, errors, watch }=createForm<{email: string;count: number}>({initialValues: {count: 0,},validators: {count: requiredValidator("Count is required"),email: [requiredValidator("This field is required"),emailValidator("Value should be email!"),],},onSubmit: async(values)=>{awaitsleep(2000);// it will automatically set loading to trueconsole.log(values);// loading is false again},});// will call the given function whenever the count changeswatch("count",(updatedCount)=>{console.log(updatedCount);});return(<div><input{...register("email")}type="email"/>{errors.email&&<pclass="error">{errors.email}</p>}{/* When you read count, it will be converted to number */}<input{...register("count")}type="number"/><buttononClick={submit}disabled={loading()}>{loading() ? "Loading..." : "Submit"}</button></div>);}functionsleep(arg0: number){thrownewError("Function not implemented.");}