v0.7.2
Improvement
export let action = async ({ request }: ActionArgs) => {
const formData = await request.formData();
const submission = parse(formData, { schema });
if (submission.intent !== 'submit' || !submission.value) {
return json(submission);
}
return json({
...submission,
// Notify the client to reset the form using `null`
payload: null,
});
};
export default function Component() {
const lastSubmission = useActionData<typeof action>();
const [form, { message }] = useForm({
// The last submission should be updated regardless the submission is successful or not
// If the submission payload is empty:
// 1. the form will be reset automatically
// 2. the default value of the form will also be reset if the document is reloaded (e.g. nojs)
lastSubmission,
})
// ...
}
New Contributors
- @lifeiscontent made their first contribution in #193
Full Changelog: v0.7.1...v0.7.2