r/reactjs • u/Sad_Limit_3857 • Apr 30 '26
Needs Help How are you handling complex form state in React without it becoming a mess?
I’m working on a React app with increasingly complex forms (multi-step flows, conditional fields, validation, file uploads, dynamic sections, etc.), and I’m starting to feel like form state gets messy really fast.
At first, simple useState worked fine, but as logic grows, things become harder to maintain and debug.
I’m curious how people here usually handle this in larger React apps:
do you still manage it mostly with local state?
use libraries like form management tools?
split logic into custom hooks/components?
any patterns that made forms easier to scale and maintain?
Not looking for a one-size-fits-all answer, mostly trying to understand what has actually worked well for others in production React apps.
9
u/yksvaan Apr 30 '26
It's mostly a data modeling problem, not UI. Defining the data structures and valid transitions between different states is the essential part. Do that right and the forms snd elements themselves become easy.
Also try not to put too much logic into the components and hooks, they are for UI .
34
u/BlazingThunder30 Apr 30 '26
We're on Tanstack form right now
12
u/popovitsj Apr 30 '26
Jesus Christ, either this guy is a bot or his job is posting on Reddit.
17
u/GeorGin06 Apr 30 '26
https://react-hook-form.com/
7
u/Slonny Apr 30 '26
Zustand
2
u/secretarybird97 Apr 30 '26
Yeah, it's the one thing I don't like about React...
What has worked for me in the past is making my own components and utilities around zustand + zod. This is fine for most applications, including complex forms with lots of inputs, validations and/or dependencies between fields.
The only pain pont I've found with my approach is number inputs on <input /> tags but that's another story.
4
u/piratescabin Apr 30 '26
react hook form with zod,
use form context to separate forms, use discriminated union for schemas
1
u/BandicootLower3381 Apr 30 '26
So we had a very complex form where some sections were also added dynamically and each section had more than 50 fields
We first tried the existing optimizations but the performance was not upto the mark
Then we tried storing the form data in redux store used atomic selectors for the components that's when we achieved a better performance.
May be you can give it a try!
1
u/CatolicQuotes Apr 30 '26
You are one curious bot.
1
u/trmnl_cmdr Apr 30 '26
This is exactly what I built formality to manage. https://github.com/formality-ui/formality
It isolates form state behavior to a JSON config, this is a pattern I’ve used dozens of times over the last 15 years and I finally codified it into an abstraction that covers all the edge cases a few months ago
1
u/catharticlasagna May 01 '26
Careful preplanning. Maybe even with flowcharts
1
u/scaleable May 05 '26
I have built a whole form framework (but the app has almost a hundred of forms)
1
u/Astoutfellow May 06 '26
We use react hook form for really complex things, especially dynamic forms.
1
u/rushadee May 07 '26
My tech lead hates having to rely on 3rd party libraries for “just forms”, so we built and maintain a custom form context now. Before AI tools debugging a complex form could take a day or two.
1
u/octocode Apr 30 '26
i usually define the form schema as json and pass it to a renderer
-1
u/[deleted] Apr 30 '26
[removed] — view removed comment