Remove value from the form on field unmount
I have 2 fields:
name
and description
. The description
is optional, and there is logic that hides the description
field.
By saying "hides," I mean this:
The scenario:
- Input a name
- Input a description
- Hide the description field
- Submit the form
- In onSubmit
callback I receive both name
and description
, but expect to receive only name
Is there a way to implement this?2 Replies
manual-lavender•3mo ago
If the value is an external state,
either with a
useEffect
or by checking in onSubmit
If the value is internal in the form state, with a listener:
@AlexGforeign-sapphireOP•3mo ago
Awesome! Thanks @Luca | LeCarbonator , the last one is exactly what I was looking for
@Luca | LeCarbonator, it turned out what I'm really looking for is this:
I made a feature request https://github.com/TanStack/form/discussions/1576