TanStackT
TanStack3mo ago
6 replies
wispy-olive

useStore vs withForm

Hey Guys, im really new to tanstack/form and i have a question regarding the usage of withForm.
I am currently refactoring a feature where I fetch a set of data from my backend and the user can change fields of the fetched data with inputs. Currently it is one big useState and the
onChange
and the mutableDataObject is prop-drilled down to every component that needs to change the data. It is a multi-step "form". Really just fields on a Page the user can edit.

Now to my question. If i wrap the whole page with my form and all steps are only conditionally rendered. What is the benefit of using
withForm
? I still need to prop drill the form instance to each component with or without the
withForm
HOC. Most of my Components currently need the whole dataObject to determine if it should render. I am currently getting the data from the useStore of the form and then rendering the fields as normal.

All i really need would be a hook to get my current form via an id to not prop-drill it. The docs only specify to use
withForm
to break big forms into smaller pieces.

Note for the screenshots: complexRisk is my fetched data and currentRisk is the mutable local data for the user
B8gAxwtk0qVoAAAAABJRU5ErkJggg.png
oCAAAAAElFTkSuQmCC.png
FtQ2kTGb6EAAAAAASUVORK5CYII.png
Was this page helpful?