Bot releases are hidden (Show)
loadData
The loadData
feature allows you to retrieve form values from an external API and set them as the initial values of a form.
Example usage:
const useLoginForm = createForm<Form>({
initialValues: {
email: "",
},
mode: "onSubmit",
loadData: async (id)=> {
try {
return await getFormValues();
} catch (e) {
return {};
}
},
});
onSubmit
TheonSubmit
feature enables you to submit a form.
Example usage:
const useLoginForm = createForm<Form>({
initialValues: {
email: "",
},
mode: "onSubmit",
onSubmit: values =>{
// post or update
}
});
Please note that the above code is just an example, and you may need to adapt it to your specific use case.
Published by jucian0 over 1 year ago
useForm() - This hook enables the seamless creation of forms in a native and intuitive manner.
const { register, errors, getErrors, setFieldValue, getValues } = useForm({
initialValues: data,
onSubmit,
});
function onSubmit(e: typeof data) {
console.log(e);
}
return (
<form {...register()}>
<Input name="name" />
<button>Submit</button>
<button typw="reset">Reset</button>
</form>
}
Published by jucian0 over 1 year ago
formReset
function.Published by jucian0 over 1 year ago
Published by jucian0 over 1 year ago
ππππ
useSyncExternalStore
integration for server rendering.Published by jucian0 over 1 year ago
ππππ
<input
{...register({
type: 'email',
name: 'email',
validate: yup.string().email().required(), //or zod
})}
/>
Published by jucian0 over 1 year ago
ππππ
handleReset
method, working in the same way of handleSubmit
.useEffect
, and useState
to useSyncExternalStore
to update the form state.Published by jucian0 about 2 years ago
React updated to 18.0.2
React DOM updated to 18.0.2
Published by jucian0 over 2 years ago
Published by jucian0 over 4 years ago
Add Support React Native