TanStack / TanStack/form

Form-level validation with onChange and arrays throws an undefined errorMap

Open
#1,709 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

v1 v2: needs investigation
Dominant language
TypeScript
Stars
6.7k
Forks
682
Avg merge
5d 18h
Merged PRs (30d)
7

Description

Describe the bug

Form-level validation with onChange and arrays throws an undefined errorMap when all fields are deleted or when a single field is removed. This issue only occurs with form-level validation using the onChange validator.

Uncaught TypeError: Cannot read properties of undefined (reading 'errorMap')
    at @tanstack_react-form.js?v=473e5c45:1136:27
    at functionalUpdate (@tanstack_react-form.js?v=473e5c45:423:42)
    at @tanstack_react-form.js?v=473e5c45:1349:22
    at Store.setState (@tanstack_react-form.js?v=473e5c45:296:22)
    at FormApi.setFieldMeta (@tanstack_react-form.js?v=473e5c45:1344:22)
    at @tanstack_react-form.js?v=473e5c45:1133:20
    at batch (@tanstack_react-form.js?v=473e5c45:255:5)
    at FormApi.validateSync (@tanstack_react-form.js?v=473e5c45:1090:7)
    at FieldApi.validate (@tanstack_react-form.js?v=473e5c45:2205:97)
    at FormApi.validateField (@tanstack_react-form.js?v=473e5c45:1080:28)
Your minimal, reproducible example

https://stackblitz.com/edit/vitejs-vite-egzzxehs?file=src%2FApp.tsx

Steps to reproduce
  1. Make a change in the form to trigger onChange event (you must see validation error for both fields)
Image
  1. Click on clear all or clean one
  2. See console logs
TanStack Form version

1.19.2

TypeScript version

5.8.3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked StackBlitz reproduction using TanStack Form 1.19.2 and follow the stack trace through FormApi.validateField, validateSync, and setFieldMeta. Compare form-level onChange validation when clearing all fields versus one array item; done means deletion no longer throws an undefined errorMap.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.