Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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};
});
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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');
});
});
4 changes: 2 additions & 2 deletions packages/react-server/src/ReactFizzHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,12 +575,12 @@ function useFormState<S, P>(
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;
};
Expand Down