-
Hi, first thanks for this package! I am trying to test it but I am getting this error when trying the first example in a rrv7 app.
Version: // contactus
import { useRemixForm, getValidatedFormData } from "remix-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import * as zod from "zod";
import { Route } from "./+types/contactus";
import { data, Form } from "react-router";
const schema = zod.object({
name: zod.string().min(1),
email: zod.string().email().min(1),
});
type FormData = zod.infer<typeof schema>;
const resolver = zodResolver(schema);
export const action = async ({ request }: Route.LoaderArgs) => {
const {
errors,
data: d,
receivedValues: defaultValues,
} = await getValidatedFormData<FormData>(request, resolver);
if (errors) {
// The keys "errors" and "defaultValues" are picked up automatically by useRemixForm
return data({ errors, defaultValues });
}
// Do something with the data
return data(d);
};
export default function MyForm() {
const {
handleSubmit,
formState: { errors },
register,
} = useRemixForm<FormData>({
mode: "onSubmit",
resolver,
});
return (
<Form onSubmit={handleSubmit} method="POST">
<label>
Name:
<input type="text" {...register("name")} />
{errors.name && <p>{errors.name.message}</p>}
</label>
<label>
Email:
<input type="email" {...register("email")} />
{errors.email && <p>{errors.email.message}</p>}
</label>
<button type="submit">Submit</button>
</Form>
);
} I am using Base stack as default configuration. |
Beta Was this translation helpful? Give feedback.
Answered by
Mat-moran
Dec 4, 2024
Replies: 1 comment
-
related with this issue upgrading to 7.0.2 fix the issue |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Mat-moran
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
related with this issue
#127
upgrading to 7.0.2 fix the issue