You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm seeing odd behavior that doesn't seem right.. I have a form (with shouldUnregister: false) with fields that are dynamically shown/hidden (unmounted) based on a radio button.
When toggling the radio button, I see the fields render as expected - they hold their previous values and state. But when I submit (and there are errors so it doesn't proceed), their values are retained but their state is reset (in particular the error state).
I would expect their state to be retained - which, again, does happen when toggling the fields on and off before submission.
This happens when manually invoking trigger as well.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Description
I'm seeing odd behavior that doesn't seem right.. I have a form (with
shouldUnregister: false
) with fields that are dynamically shown/hidden (unmounted) based on a radio button.When toggling the radio button, I see the fields render as expected - they hold their previous values and state. But when I submit (and there are errors so it doesn't proceed), their values are retained but their state is reset (in particular the error state).
I would expect their state to be retained - which, again, does happen when toggling the fields on and off before submission.
This happens when manually invoking
trigger
as well.CSB
https://codesandbox.io/s/flamboyant-lederberg-cx9ve8?file=/src/App.js
Steps to reproduce
Expected: After step 7, there should still be an error on Last Name field
Env
Am I doing something wrong? Am I thinking about this wrong? Any insight is appreciated.
Thank you
Beta Was this translation helpful? Give feedback.
All reactions