Identify form resets incomponents using useField #4455
Unanswered
adrianrudnik
asked this question in
Q&A
Replies: 1 comment
-
Alternatively, you could check if There are no plans at the moment to add hooks like |
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
-
Is there a way to react to parents
resetForm()
calls inside an input component that is implemented based onuseField()
?Right now, there are two cases I need to react to:
useForm()
, leading toonMounted
event inside the input component that usesuseField()
. This one is the basic one and works without hassle.resetForm()
, resetting values on the already mounted component and reset the input component back to a "default" state, not just the "values".My use case is a grouped input component that has an input text and a dropdown (imagine "label" input text and "language" dropdown). The dependency is that the input text changes based on the dropdown.
Using a
resetForm()
right now pushes "default" values down to the input component instance, but I have no idea how I identify that this is a reset and not just a value change. I need to reset the dropdown into a clean state as well (i.e. back to users' default language or the first available one as dropdown value, then reset the input text).I tried some combinations of
useField
s ownvalue
andmeta.dirty
, but there is nometa.pristine
ormeta.reset
towatch
and identify form resets reliably.Is there a way how a component can identify a complete form reset and do extra stuff involved with that?
Beta Was this translation helpful? Give feedback.
All reactions