Skip to content

issue Cannot read properties of undefined (reading 'onServer') #1946

@solo-samurai

Description

@solo-samurai

Describe the bug

Uncaught TypeError: Cannot read properties of undefined (reading 'onServer')
at FormApi.ts:1699:17
at batch (scheduler.ts:145:5)
at FormApi.validateSync (FormApi.ts:1656:5)
at FieldApi.validate (FieldApi.ts:1883:19)
at FieldApi.setValue (FieldApi.ts:1371:12)
at FieldApi.handleChange (FieldApi.ts:1907:10)
at InputField[.onChange] (index.tsx:129:28)
at mergeProps.js:133:22
at executeDispatch (react-dom-client.development.js:20543:9)
at runWithFiberInDEV (react-dom-client.development.js:986:30)
at processDispatchQueue (react-dom-client.development.js:20593:19)
at react-dom-client.development.js:21164:9
at batchedUpdates$1 (react-dom-client.development.js:3377:40)
at dispatchEventForPluginEventSystem (react-dom-client.development.js:20747:7)
at dispatchEvent (react-dom-client.development.js:25693:11)
at dispatchDiscreteEvent (react-dom-client.development.js:25661:11)
(anonymous) @ FormApi.ts:1699
batch @ scheduler.ts:145
FormApi.validateSync @ FormApi.ts:1656
FieldApi.validate @ FieldApi.ts:1883
FieldApi.setValue @ FieldApi.ts:1371
FieldApi.handleChange @ FieldApi.ts:1907
InputField[.onChange] @ index.tsx:129
(anonymous) @ mergeProps.js:133
executeDispatch @ react-dom-client.development.js:20543
runWithFiberInDEV @ react-dom-client.development.js:986
processDispatchQueue @ react-dom-client.development.js:20593
(anonymous) @ react-dom-client.development.js:21164
batchedUpdates$1 @ react-dom-client.development.js:3377
dispatchEventForPluginEventSystem @ react-dom-client.development.js:20747
dispatchEvent @ react-dom-client.development.js:25693
dispatchDiscreteEvent @ react-dom-client.development.js:25661

Your minimal, reproducible example

non

Steps to reproduce

const schema = z.object({
	name: z.string().min(1, "Name is required"),
	search: z.string().optional(),
	regions: z
		.array(
			z.object({
				country: z.string().min(1, "Country is required"),
				state: z.string().optional(),
			})
		)
		.min(1, "At least one region is required"),
});
const form = useAppForm({
		validators: {
			onSubmit: schema,
		},
		formId: "shipping-zone-form",
		defaultValues: initialValues,
		onSubmit: ({ value }) => onSubmit(value),
	});

Expected behavior

Every time I update the region and call form.setFieldValue("regions", newRegions); it break.
Before then, it works

How often does this bug happen?

Every time

Screenshots or Videos

Image

Platform

windows

TanStack Form adapter

react-form

TanStack Form version

1.27.5

TypeScript version

5.9.3

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions