Skip to content
Discussion options

You must be logged in to vote

FieldApi isn't meant to be written by hand as a prop type — those 23 generics are internal plumbing, and there's no InferFieldApi helper (as @aymenhmaidiwastaken noted). The idiomatic way to get a reusable component with a typed field is the form composition API, where the field type comes from context instead of props.

Set up the contexts once:

// form-context.ts
import { createFormHookContexts } from '@tanstack/react-form'

export const { fieldContext, formContext, useFieldContext } =
  createFormHookContexts()

Register your reusable component as a field component:

// app-form.ts
import { createFormHook } from '@tanstack/react-form'
import { fieldContext, formContext } from './form-cont…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@hadikman
Comment options

Answer selected by hadikman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants