Skip to content

Commit

Permalink
Fix type errors for form actions in React v19 stable.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrause committed Dec 5, 2024
1 parent 713ddde commit db9b541
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/components/forms/context/Form/Form.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ type Story = StoryObj<FormArgs>;
const FormWithState = (props: React.ComponentProps<typeof Form>) => {
const action = async (previousState: unknown, formData: FormData): Promise<null> => {
if (typeof props.action === 'function') {
return props.action?.(formData) ?? null;
await props.action?.(formData);
return null;
}
return null;
};
Expand Down Expand Up @@ -77,7 +78,7 @@ export const Standard: Story = {
//onSubmit: (event) => { event.preventDefault(); console.log('submit', event); },
action: (formData) => {
//console.log('action', formData.get('field-1'));
return [...formData.entries()].reduce(
const result = [...formData.entries()].reduce(
(acc, [fieldKey, field]) => {
if (Object.hasOwn(acc, fieldKey)) {
console.warn(`Found duplicate entries for key ${fieldKey}`);
Expand All @@ -87,6 +88,7 @@ export const Standard: Story = {
},
{} as Record<string, unknown>,
);
return; // FIXME: form actions now return type `void | Promise<void>`
},
children: (
<>
Expand Down

0 comments on commit db9b541

Please sign in to comment.