From b510d6297af506b8b69d1b750d753a4e26f4fb93 Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Tue, 29 Aug 2023 21:21:38 -0400 Subject: [PATCH] Fix: action -> target I mixed these up --- .../src/__tests__/ReactFlightDOMForm-test.js | 6 +++--- packages/react-server/src/ReactFizzHooks.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMForm-test.js b/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMForm-test.js index 7e1955b753107..c57a8dd495555 100644 --- a/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMForm-test.js +++ b/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMForm-test.js @@ -354,7 +354,7 @@ describe('ReactFlightDOMForm', () => { // @gate enableFormActions // @gate enableAsyncActions - it("useFormState can change the action's target with the `permalink` argument", async () => { + it('useFormState can change the action URL with the `permalink` argument', async () => { const serverAction = serverExports(function action(prevState) { return {state: prevState.count + 1}; }); @@ -386,7 +386,7 @@ describe('ReactFlightDOMForm', () => { const span = container.getElementsByTagName('span')[0]; expect(span.textContent).toBe('Count: 1'); - expect(form.target).toBe('/permalink'); + expect(form.action).toBe('http://localhost/permalink'); }); // @gate enableFormActions @@ -427,6 +427,6 @@ describe('ReactFlightDOMForm', () => { const span = container.getElementsByTagName('span')[0]; expect(span.textContent).toBe('Count: 1'); - expect(form.target).toBe('/permalink'); + expect(form.action).toBe('http://localhost/permalink'); }); }); diff --git a/packages/react-server/src/ReactFizzHooks.js b/packages/react-server/src/ReactFizzHooks.js index 377c21a9fe637..e42725f928e73 100644 --- a/packages/react-server/src/ReactFizzHooks.js +++ b/packages/react-server/src/ReactFizzHooks.js @@ -575,12 +575,12 @@ function useFormState( dispatch.$$FORM_ACTION = (prefix: string) => { // $FlowIgnore[prop-missing] const metadata: ReactCustomFormAction = boundAction.$$FORM_ACTION(prefix); - // Override the target URL + // Override the action URL if (permalink !== undefined) { if (__DEV__) { checkAttributeStringCoercion(permalink, 'target'); } - metadata.target = permalink + ''; + metadata.action = permalink + ''; } return metadata; };