Skip to content

Conversation

@gustavoalvesleao
Copy link
Contributor

When using the hook useFocusInvalid, introduced in Schema Validation lesson 01. Zod schema validation, we have a problem: The actionData.status is always equals to 'error', which means the useEffect only runs once. This leads us not having the focus being set properly after the second "invalid" submission attempt:

Screenshare.-.2024-01-23.6_37_09.AM.mp4

* Just a note that this was not occurring in the previous lessons, as actionData was used as a dependency and therefore was new after every submission

The proposed solution is simply to add is to add isSubmitting in the boolean that forms hasErrors, so we can have the useEffect running after every submission:

Screenshare.-.2024-01-23.6_07_35.AM.mp4

Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks reasonable to me! Thanks!

I'm glad we can rely on conform so we don't have bugs like this in the end 😅

@kentcdodds kentcdodds merged commit acaa0ce into epicweb-dev:main Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants