Skip to content
Discussion options

You must be logged in to vote

There's two requirements you have for showing errors:

  • isTouched: It must be touched (blurred or changed). If it should only be blurred, use isBlurred instead.
  • The user may have tried submitting without touching the field. Check for submissionAttempts > 0

Since you're using field components, you should use useStore to ensure it's reactive.

const isTouched = useStore(field.store, state => state.meta.isTouched)
const submissionAttempts = useStore(field.form.store, state => state.submissionAttempts)

const showError = isTouched || submissionAttempts > 0

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Micnubinub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants