Skip to content
Source
Sign inSign up
TanStack/form

[v2] Fix(vue): Rerender createFormHook field components and keep them connected after reset #2392

Closedawdr74100(GitHub profile, opens in a new tab)wants to merge 1 commit intoalpha fromrefs/pull/2392/headopened

Showing 6 changed files with 15 additions and 6 deletions (loading 3).

x
0 of 6 viewed, 6 left
5 additions and 0 deletions.changeset/quiet-fields-follow.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/vue-form': patch
+---
+​
+Fix: Field components registered through `createFormHook` now rerender when their field state changes and stay connected to the current field API after `form.reset()`
5 additions and 5 deletionspackages/vue-form/src/AppForm/contexts.lib.tsModified
View file
@@ -1,16 +1,16 @@
import { inject } from 'vue'
-import type { InjectionKey } from 'vue'
+import type { ComputedRef, InjectionKey } from 'vue'
import type { AnyInternalFieldApi } from '@tanstack/form-core/internals'
import type { InternalVueFormApi } from '../VueForm/VueFormApi.lib'
​
export const FormContext = Symbol(
'TanStackForm.FormContext',
) as InjectionKey<InternalVueFormApi>
-export const FieldContext = Symbol(
- 'TanStackForm.FieldContext',
-) as InjectionKey<AnyInternalFieldApi>
+export const FieldContext = Symbol('TanStackForm.FieldContext') as InjectionKey<
+ ComputedRef<AnyInternalFieldApi>
+>
​
-export function useFieldContext(): AnyInternalFieldApi {
+export function useFieldContext(): ComputedRef<AnyInternalFieldApi> {
const field = inject(FieldContext)
if (field === undefined) {
throw new Error(