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:
parent
36319faf9c
commit
3f8a75f93c
1 changed files with 1 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue