Replies: 2 comments
-
can you share a simple codesandbox with your implementation above? |
Beta Was this translation helpful? Give feedback.
0 replies
-
The |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
HI, this may be just a React question, but I've only encountered it using Hook Forms, so I wanted to ask here.
I have a form with several fields requiring non-trivial validation, but the JSX is highly redundant across the fields so I'd like to refactor the repeating part into a React.Fragment. This repeating section has the usual conditional rendering of validation error messages. However, after I do the refactoring, the form validation dependent conditional rendering never fires. Is there a reason this wouldn't work with Hook Forms?
Here's the starting code:
Then refactored, it looks like this:
with the refactored method like this:
It renders just fine, but the conditional error rendering never fires when bad input are provided in the field. I tried wrapping the whole fragment in a
<div>
, but that made no difference.Any suggestions would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions