Cheatsheet

Cheatsheet

Decision rules

  • Need a value to update the UI? → subscribe (useSelector/form.Subscribe, ch014). Never read form.state unsubscribed and expect re-renders.
  • Need to react to a change with a side effect (not an error message)? → listener (ch015), not a validator that returns undefined.
  • Need one field to check another field's value?onChangeListenTo/onBlurListenTo + fieldApi.form.getFieldValue (ch013), not just a form-level validator alone.
  • Need a dynamic list?mode="array" + the push/remove/insert/replace/swap/move value methods (ch011). Never reassign field.state.value directly.
  • Building more than 1-2 forms? → set up createFormHook first (ch020), then build every form with useAppForm.
  • Errors too aggressive before first submit?revalidateLogic + onDynamic (ch009).
  • Data loads async before the form should render? → gate useForm behind isLoading (ch010), don't try to update defaultValues reactively after the fact.
  • Building for TanStack Start/Next.js/Remix with server validation? → install the matching -start/-nextjs/-remix package (ch002) and follow the createServerValidate + mergeForm pattern (ch022) — don't hand-roll it.
  • Choosing vs. React Hook Form? → TanStack Form if you need multi-framework support or robust deep/array-field TypeScript inference; React Hook Form if you want the more mature React-only devtools ecosystem today (ch004).

Validator timing quick reference

TimingField-level syncField-level asyncForm-level syncForm-level async
MountonMountonMount
ChangeonChangeonChangeAsynconChangeonChangeAsync
BluronBluronBlurAsynconBluronBlurAsync
SubmitonSubmitonSubmitAsynconSubmitonSubmitAsync
Dynamic (needs revalidateLogic)onDynamiconDynamicAsynconDynamiconDynamicAsync

Array field methods (FieldApi and FormApi, ch011/ch026)

MethodEffect
pushValue(value)Append to end
removeValue(index)Delete at index
insertValue(index, value)Insert at index, shift right
replaceValue(index, value)Overwrite at index
swapValues(a, b)Exchange two positions
moveValue(a, b)Relocate one item
clearValues()Empty the array

Framework quick-reference (ch029)

FrameworkForm callField mechanism
React / PreactuseForm()form.Field render prop
VueuseForm()form.Field scoped slot
Solid / SveltecreateForm()form.Field children fn / snippet
AngularinjectForm()TanStackField directive
Litnew TanStackFormController(this, {...})this.#form.field({name}, cb)

Debugging quick reference (ch023)

SymptomLikely causeFix
"uncontrolled to controlled" warningfield missing from defaultValuesseed every field's default explicitly
field.state.value is unknownform type shape too complexsplit via FormGroup (ch012) / composition (ch020)
"excessively deep type instantiation"library-internal TS generic depthnot a runtime bug; report upstream
cross-field validator looks stalemissing onChangeListenTo/onBlurListenToadd the listen-to array (ch013)
whole form re-renders on any keystrokereading form.state without a selectoruse useSelector/form.Subscribe (ch014)