Skip to content

getFieldState

State of the field

getFieldState: object

This method is introduced in react-hook-form (v7.25.0) to return individual field state. It's useful in case you are trying to retrieve nested field state in a typesafe way.

Props

NameTypeDescription
namestring

registered field name.

formState

object

When set to true, field error will be retained.

Return

NameTypeDescription
isDirtyboolean

field is modified.

Condition: subscribe to dirtyFields.

isTouch

boolean

field has received a focus and blur event.

Condition: subscribe to touchedFields.

invalid

boolean

field is not valid.

Condition: subscribe to errors.

error

undefined | FieldError

field error object.

Condition: subscribe to errors.

Rules

  • name need to match registered field name.

  • formState will need to subscribed.

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