@samitouri / QOS-React-1 / commits / 2fba484cd0

useFormState fix: action -> target (#27309)

I mixed these attributes up in https://github.com/facebook/react/pull/27302

Andrew Clark committed Aug 29, 2023 at 22:17 UTC 2fba484cd095ea79b940364cea5107fa4ca9f0c8
2 files changed +5 -5
packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMForm-test.js
+3 -3
@@ -354,7 +354,7 @@ describe('ReactFlightDOMForm', () => {
354
355 // @gate enableFormActions
356 // @gate enableAsyncActions
357 - it("useFormState can change the action's target with the `permalink` argument", async () => {
357 + it('useFormState can change the action URL with the `permalink` argument', async () => {
358 const serverAction = serverExports(function action(prevState) {
359 return {state: prevState.count + 1};
360 });
@@ -386,7 +386,7 @@ describe('ReactFlightDOMForm', () => {
386 const span = container.getElementsByTagName('span')[0];
387 expect(span.textContent).toBe('Count: 1');
388
389 - expect(form.target).toBe('/permalink');
389 + expect(form.action).toBe('http://localhost/permalink');
390 });
391
392 // @gate enableFormActions
@@ -427,6 +427,6 @@ describe('ReactFlightDOMForm', () => {
427 const span = container.getElementsByTagName('span')[0];
428 expect(span.textContent).toBe('Count: 1');
429
430 - expect(form.target).toBe('/permalink');
430 + expect(form.action).toBe('http://localhost/permalink');
431 });
432 });
packages/react-server/src/ReactFizzHooks.js
+2 -2
@@ -575,12 +575,12 @@ function useFormState<S, P>(
575 dispatch.$$FORM_ACTION = (prefix: string) => {
576 // $FlowIgnore[prop-missing]
577 const metadata: ReactCustomFormAction = boundAction.$$FORM_ACTION(prefix);
578 - // Override the target URL
578 + // Override the action URL
579 if (permalink !== undefined) {
580 if (__DEV__) {
581 checkAttributeStringCoercion(permalink, 'target');
582 }
583 - metadata.target = permalink + '';
583 + metadata.action = permalink + '';
584 }
585 return metadata;
586 };