0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-13 22:11:20 -05:00

fix: keep action state up to date each submit

This commit is contained in:
bholmesdev 2024-05-16 13:59:11 -04:00
parent 36319faf9c
commit 3f8a75f93c

View file

@ -4,6 +4,7 @@ type FormFn<T> = (formData: FormData) => Promise<T>;
export function withState<T>(action: FormFn<T>) {
const callback = async function (state: T, formData: FormData) {
formData.set('_astroActionState', JSON.stringify(state));
return action(formData);
};
if (!('$$FORM_ACTION' in action)) return callback;