mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
useFormState fix: action -> target (#27309)
I mixed these attributes up in https://github.com/facebook/react/pull/27302
This commit is contained in:
@@ -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');
|
||||
});
|
||||
});
|
||||
|
||||
+2
-2
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user