From 84189b6511dc2a14bcfe608696f56a64c2046f39 Mon Sep 17 00:00:00 2001 From: Ben Holmes Date: Tue, 30 Jul 2024 11:04:10 -0400 Subject: Actions: New fallback behavior with `action={actions.name}` (#11570) * feat: support _astroAction query param * feat(test): _astroAction query param * fix: handle _actions requests from legacy fallback * feat(e2e): new actions pattern on blog test * feat: update React 19 adapter to use query params * fix: remove legacy getApiContext() * feat: ActionQueryStringInvalidError * fix: update error description * feat: ActionQueryStringInvalidError * chore: comment on _actions skip * feat: .queryString property * chore: comment on throw new Error * chore: better guess for "why" on query string * chore: remove console log * chore: changeset * chore: changeset --- packages/integrations/react/src/actions.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'packages/integrations/react/src') diff --git a/packages/integrations/react/src/actions.ts b/packages/integrations/react/src/actions.ts index 336d32220..bc45e28ee 100644 --- a/packages/integrations/react/src/actions.ts +++ b/packages/integrations/react/src/actions.ts @@ -25,8 +25,9 @@ export function experimental_withState(action: FormFn) { callback.$$FORM_ACTION = action.$$FORM_ACTION; // Called by React when form state is passed from the server. // If the action names match, React returns this state from `useActionState()`. - callback.$$IS_SIGNATURE_EQUAL = (actionName: string) => { - return action.toString() === actionName; + callback.$$IS_SIGNATURE_EQUAL = (incomingActionName: string) => { + const actionName = new URLSearchParams(action.toString()).get('_astroAction'); + return actionName === incomingActionName; }; // React calls `.bind()` internally to pass the initial state value. -- cgit v1.2.3