Skip to content

ErrorMessage

An error message component to handle errors

ErrorMessage: Component

A simple component to render associated input's error message.

npm install @hookform/error-message

Props

NameTypeRequiredDescription
namestringName of the field.
errorsobjecterrors object from React Hook Form. Optional if you are using FormProvider.
messagestring | React.ReactElementInline error message.
asReact.ElementType | stringWrapper component or HTML tag. For example: as="span" or as={<Text />}
render({ message: string | React.ReactElement, messages?: Object}) => anyThis is a render prop for rendering error message or messages.

Note: you need to set criteriaMode to 'all' for using messages.

Examples

Thank you for your support

If you find React Hook Form to be useful in your project, please consider to star and support it.

Edit