TanStackT
TanStack8mo ago
3 replies
few-sapphire

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:

const [showDescription, setShowDescription] = useState(true);

...

{showDescription && <form.Field name="description" ... />}


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?
Was this page helpful?