Skip to content
Source
Sign inSign up
TanStack/form

fix: prevent initialFormState from overriding client values during merge #2096

OpenMishra-coder(GitHub profile, opens in a new tab)wants to merge 3 commits intomain fromrefs/pull/2096/headopened

Showing 4 changed files with 24 additions and 4 deletions (loading 1).

x
0 of 4 viewed, 4 left
1 addition and 2 deletionspackages/react-form-nextjs/src/createServerValidate.tsModified
View file
@@ -133,6 +133,5 @@
errorMap: {
onServer: undefined,
- values: undefined,
errors: [],
-}
+} as unknown as ServerFormState<any, undefined>
22 additions and 0 deletionspackages/react-form-nextjs/tests/createServerValidate.spec.tsxAdded
View file
@@ -0,0 +1,22 @@
+import { describe, expect, it } from 'vitest'
+import { mutateMergeDeep } from '@tanstack/react-form'
+import { initialFormState } from '../src/createServerValidate'
+​
+describe('initialFormState', () => {
+ it('should not contain values property', () => {
+ expect(initialFormState).not.toHaveProperty('values')
+ })
+​
+ it('should not override client values when merged', () => {
+ const clientState = {
+ values: { name: 'client-name' },
+ errors: [],
+ errorMap: {}