"Nested" Forms #1458
Unanswered
michaelcamper
asked this question in
Q&A
"Nested" Forms
#1458
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a
TaskForm
with a pretty complex UI. I either want to use this form standalone (to create a new task or add an existing task) or insideTaskList
component that allows to add and edit a list of tasks.Therefore, I want to
useForm
inTaskList
and somehow pass aform
to all theTaskForm
s inside the list.Here is my best attempt to achieve this:
Here's another approach that worked, but is a TS mess:
TaskList
] Wrap thetasksField
inside<taskFormContext.Provider value={form}>...</taskFormContext.Provider>
TaskForm
] Add an optionalprefix
prop and prepend the field namesTaskForm
] ReplaceuseTaskForm
withuseTaskFormContext
Beta Was this translation helpful? Give feedback.
All reactions