Files
diplomarbeitsportal/src/blocks/Form/Error/index.tsx
2025-03-25 10:53:07 +01:00

16 lines
356 B
TypeScript

'use client'
import * as React from 'react'
import { useFormContext } from 'react-hook-form'
export const Error = ({ name }: { name: string }) => {
const {
formState: { errors },
} = useFormContext()
return (
<div className="mt-2 text-red-500 text-sm">
{(errors[name]?.message as string) || 'This field is required'}
</div>
)
}