You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a generic way to iterate through every error in the formState.errors and render them?
I tried using the @hookform/error-message component, but it requires to be fed a name of the field containing the errors, but I have a ton of fields over a funnel so this is not viable.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have controlled form fields (MUI) and one of them looks like this:
...
name={
myarray.${myindex}.mysubarray.0.someproperty.finalproperty
}...
Is there a generic way to iterate through every error in the formState.errors and render them?
I tried using the @hookform/error-message component, but it requires to be fed a name of the field containing the errors, but I have a ton of fields over a funnel so this is not viable.
I need something like this:
...Object.entries(messages).map(([type, message]) =>
{message}
)but to get the errors from formState.errors.
formState.errors can contain several arrays, for example, formState.errors.myarray1, formState.errors.myarray2 etc.
Any thoughts?
Beta Was this translation helpful? Give feedback.
All reactions