TanStackT
TanStack3mo ago
7 replies
dangerous-fuchsia

How to type formOptions

Hy everyone, someone can say me, if it's possible a type formOptions and if yes how to ?

Code :
import { useAppForm } from '@/context/FormContext';
import { formOptions } from '@tanstack/form-core';

const sortedFormOpts = formOptions({
  defaultValues: {
    projects: '',
    profiles: '', 
    opportunities: '',
    todos: '',
    quotes: '',
    beginMoment: '',
    endMoment: '',
  },
});
export function useSortedForm() {
  return useAppForm({ ...sortedFormOpts });
}

export type SortedFormType = ReturnType<typeof useSortedForm>;
export type SortedFormValues = (typeof sortedFormOpts)['defaultValues'];
Was this page helpful?