fix: add condition to re-trigger focus upon new submissions #36
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When using the hook
useFocusInvalid, introduced in Schema Validation lesson 01. Zod schema validation, we have a problem: TheactionData.statusis always equals to'error', which means theuseEffectonly 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
actionDatawas used as a dependency and therefore was new after every submissionThe proposed solution is simply to add is to add
isSubmittingin the boolean that formshasErrors, so we can have theuseEffectrunning after every submission:Screenshare.-.2024-01-23.6_07_35.AM.mp4