-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[@shopify/react-form] form.submitErrors
is not populated when returning {status: "fail"}
#2500
Comments
I now understand what is happening. Inside the I'm not sure what the purpose of this early exit is. I would vote to remove it. The mounted ref flips to |
I used some time to figure out it's not working in react 18! Return submiterrors = [] import { FormErrors } from "@components/FormErrors";
import {
Button,
Card,
Form,
FormLayout,
Frame,
Page,
TextField,
} from "@shopify/polaris";
import { useField, useForm } from "@shopify/react-form";
export default () => {
const {
fields: { phone },
submit,
submitErrors,
} = useForm({
fields: {
phone: useField(""),
},
onSubmit: async (fieldValues) => {
return {
status: "fail",
errors: [{ field: ["phone"], message: "bad form data" }],
};
},
});
console.log(submitErrors);
return (
<Frame>
<div className="inline-block align-middle">
<Page
narrowWidth
title="Receive password by phone"
breadcrumbs={[{ content: "Login", url: "/" }]}
>
<FormErrors errors={submitErrors} />
<Card sectioned>
<Form onSubmit={submit}>
<FormLayout>
<TextField label="Phone" autoComplete="phone" {...phone} />
<Button submit>Receive password</Button>
</FormLayout>
</Form>
</Card>
</Page>
</div>
</Frame>
);
}; |
Did you have a solution to this problem? |
I use patch-package with this diff: |
This is fixed in Next.js 13.2. I suggest closing this. Here's a stackblitz to confirm. |
it's still a problem, strict mode is breaking it! |
@jamalsoueidan @jokull There is a linked pull request #2637 which has snapshot versions included. I've included them here in this comment as well for your convenience. If you're able to test these snapshot versions and confirm if the issue is resolved for you I would appreciate it 🙂 You might need to install both, but hopefully the package manager of your choosing resolves the snapshot version of yarn add @shopify/react-form@0.0.0-snapshot-20230425154318 yarn add @shopify/react-hooks@0.0.0-snapshot-20230425154318 Thanks in advance! |
LGTM! (BTW I might have spoken too soon on it being fixed back there in March - I think I just didn't have strict mode toggled on). |
@jokull you have time to test it? Since I don't :( |
Overview
In a very simple example
submitErrors
is not populated.Consuming repo
Made a reproducable example. https://stackblitz.com/edit/vitejs-vite-qctwdk?file=src/App.tsx
Checklist
The text was updated successfully, but these errors were encountered: