fireship.io
fireship.io copied to clipboard
courses/react-next-firebase/admin-form-validation/
Form Validation
Add form validation with react-hook-forms
https://fireship.io/courses/react-next-firebase/admin-forms/
If you are getting any errors related to useForm or path.split is not a function. A new format is required for the react hooks.
you must create the errors hook from the formstate property and you much also change the way you use the register hook.
const {
register,
handleSubmit,
reset,
watch,
formState: { errors },
formState,
} = useForm({
defaultValues,
mode: "onChange",
});
and
<textarea
{...register("content", {
maxLength: { value: 30000, message: "Content is too long!" },
minLength: { value: 10, message: "Content is too short!" },
required: { value: true, message: "Content is required" },
})}
></textarea>
Thanks, @Jimbo Jeff needs to update this