Replies: 3 comments 3 replies
-
For more context I'm having a use case where I need to use the form API in múltiple nested react components and passing as a prop is not an option. Currently I'm doing this, but it seems like I'm reinventing the wheel
|
Beta Was this translation helpful? Give feedback.
-
I am also looking for an example of how to use |
Beta Was this translation helpful? Give feedback.
-
i just recently found how to use it based on the docs (although the documentation is not very descriptive) so based on the param, you should pass like this when you use import { useForm } from '@tanstack/react-form';
const form = useForm({...}) or import { useAppForm } from '@/components/react-form';
const form = useAppForm({...}) then, you can pass the form into the useField import { useField } from '@tanstack/react-form';
const field = useField({
form,
name='example_field',
mode='array', // or any mode based on docs
...fieldOptions
}) where fieldOptions is params you passed like the usual params in <form.Field ... > or <form.AppField ...> More info about the available properties on field options |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I've been trying to figure it out, but I'm having a hard time.
Also, I found that createUseField is in the docs but it's not exposed as part of the module
https://tanstack.com/form/latest/docs/framework/react/reference/useField#createusefield
Beta Was this translation helpful? Give feedback.
All reactions