Skip to content
Discussion options

You must be logged in to vote

Hey @billgun!

I extended my form.tsx.

Here's what I did:

const FormRootError = React.forwardRef<
  HTMLParagraphElement,
  React.HTMLAttributes<HTMLParagraphElement>
>(({ className, ...props }, ref) => {
  const { errors } = useFormState()
  const rootError = errors.root
  if (!rootError) {
    return null
  }
  return (
    <p
      ref={ref}
      className={cn("text-destructive text-sm font-medium", className)}
      {...props}
    >
      {rootError.message}
    </p>
  )
})
FormRootError.displayName = "FormRootError"

I'll create a PR for this.

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@illustrofia
Comment options

Answer selected by billgun
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants