Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 3 additions & 52 deletions packages/react-form/src/useField.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client'

import { useMemo, useRef, useState } from 'react'
import { useMemo, useState } from 'react'
import { useStore } from '@tanstack/react-store'
import { FieldApi, functionalUpdate } from '@tanstack/form-core'
import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'
Expand All @@ -15,42 +15,9 @@ import type {
FormAsyncValidateOrFn,
FormValidateOrFn,
} from '@tanstack/form-core'
import type { FunctionComponent, ReactElement, ReactNode } from 'react'
import type { FunctionComponent, ReactNode } from 'react'
import type { UseFieldOptions, UseFieldOptionsBound } from './types'

interface ReactFieldApi<
TParentData,
TFormOnMount extends undefined | FormValidateOrFn<TParentData>,
TFormOnChange extends undefined | FormValidateOrFn<TParentData>,
TFormOnChangeAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
TFormOnBlur extends undefined | FormValidateOrFn<TParentData>,
TFormOnBlurAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
TFormOnSubmit extends undefined | FormValidateOrFn<TParentData>,
TFormOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
TFormOnDynamic extends undefined | FormValidateOrFn<TParentData>,
TFormOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
TFormOnServer extends undefined | FormAsyncValidateOrFn<TParentData>,
TPatentSubmitMeta,
> {
/**
* A pre-bound and type-safe sub-field component using this field as a root.
*/
Field: FieldComponent<
TParentData,
TFormOnMount,
TFormOnChange,
TFormOnChangeAsync,
TFormOnBlur,
TFormOnBlurAsync,
TFormOnSubmit,
TFormOnSubmitAsync,
TFormOnDynamic,
TFormOnDynamicAsync,
TFormOnServer,
TPatentSubmitMeta
>
}

/**
* A type representing a hook for using a field in a form with the given form data type.
*
Expand Down Expand Up @@ -305,23 +272,7 @@ export function useField<
TFormOnDynamicAsync,
TFormOnServer,
TPatentSubmitMeta
> &
ReactFieldApi<
TParentData,
TFormOnMount,
TFormOnChange,
TFormOnChangeAsync,
TFormOnBlur,
TFormOnBlurAsync,
TFormOnSubmit,
TFormOnSubmitAsync,
TFormOnDynamic,
TFormOnDynamicAsync,
TFormOnServer,
TPatentSubmitMeta
> = reactiveFieldApi as never

extendedApi.Field = Field as never
> = reactiveFieldApi as never
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Document the breaking removal of field.Field in release notes / migration guide.

Dropping the ReactFieldApi augmentation and the extendedApi.Field = … assignment is a public-API breaking change: any consumer using <form.Field>{(field) => <field.Field …/>}</form.Field> will now see a runtime TypeError: field.Field is not a function (and a TS error). The PR title is fix:, but per Conventional Commits this should be surfaced as a breaking change (e.g. fix!: or a BREAKING CHANGE: footer) so the changeset/semver bump and migration notes are generated correctly. Worth calling out the recommended replacement (use the outer form.Field or useField directly) in the changelog.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/react-form/src/useField.tsx` at line 275, The PR removed the
ReactFieldApi augmentation and the extendedApi.Field assignment which breaks
consumers using field.Field (e.g., in <form.Field>{(field) => <field.Field
.../>}</form.Field>); update the release notes and migration guide and ensure
the commit includes a Conventional Commits breaking change marker (either use
fix!: or add a BREAKING CHANGE: footer) that explains the removal, cites the
affected symbols (ReactFieldApi, extendedApi.Field, field.Field), and documents
the recommended replacements (use the outer form.Field or call useField
directly) with a short example and any migration steps.


return extendedApi
}, [
Expand Down
Loading