Skip to content

Commit 2fba484

Browse files
authored
useFormState fix: action -> target (#27309)
I mixed these attributes up in #27302
1 parent ddff504 commit 2fba484

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMForm-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ describe('ReactFlightDOMForm', () => {
354354

355355
// @gate enableFormActions
356356
// @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 () => {
358358
const serverAction = serverExports(function action(prevState) {
359359
return {state: prevState.count + 1};
360360
});
@@ -386,7 +386,7 @@ describe('ReactFlightDOMForm', () => {
386386
const span = container.getElementsByTagName('span')[0];
387387
expect(span.textContent).toBe('Count: 1');
388388

389-
expect(form.target).toBe('/permalink');
389+
expect(form.action).toBe('http://localhost/permalink');
390390
});
391391

392392
// @gate enableFormActions
@@ -427,6 +427,6 @@ describe('ReactFlightDOMForm', () => {
427427
const span = container.getElementsByTagName('span')[0];
428428
expect(span.textContent).toBe('Count: 1');
429429

430-
expect(form.target).toBe('/permalink');
430+
expect(form.action).toBe('http://localhost/permalink');
431431
});
432432
});

packages/react-server/src/ReactFizzHooks.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,12 +575,12 @@ function useFormState<S, P>(
575575
dispatch.$$FORM_ACTION = (prefix: string) => {
576576
// $FlowIgnore[prop-missing]
577577
const metadata: ReactCustomFormAction = boundAction.$$FORM_ACTION(prefix);
578-
// Override the target URL
578+
// Override the action URL
579579
if (permalink !== undefined) {
580580
if (__DEV__) {
581581
checkAttributeStringCoercion(permalink, 'target');
582582
}
583-
metadata.target = permalink + '';
583+
metadata.action = permalink + '';
584584
}
585585
return metadata;
586586
};

0 commit comments

Comments
 (0)