The field left. Its data stayed.
Hiding or unmounting an input does not necessarily remove its value from the form’s state. Decide which values belong in the active submission.
This is a TanStack Form example with an application-specific field wrapper, not a universal React unmount rule. Preserve drafts deliberately; clear irrelevant values or shape the outgoing payload.
Understand it. Then fix it.
The useful part
Hiding or unmounting an input does not necessarily remove its value from the form’s state. Decide which values belong in the active submission.
Make the rule explicit
This is a TanStack Form example with an application-specific field wrapper, not a universal React unmount rule. Preserve drafts deliberately; clear irrelevant values or shape the outgoing payload.
// Build the payload from the active branch.
const payload = values.type === "business"
? values
: { type: values.type, name: values.name };Code blocks are teaching excerpts. Keep the surrounding error handling and application requirements.
Save the code excerpts ↓Read the full transcript
I fired this form field. Why is it still on the payroll? Switch from business to personal. Company field? Gone. Hit submit. Zombie Corp is still in the payload. So hiding it doesn’t clear it? Right. The input’s gone. The value’s still in the form. Clear company when they choose Personal. This handler sets the account type to personal, then clears company. Connect it to the Personal option’s onChange. Now submit. No company in the request. Your schema must allow company to be absent for personal accounts. A wizard is different. Keep useful drafts, but build the request from the active branch. You fired the field. It still gets paid… in the payload.