New release v4.0.0 π π π₯³
Features
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.