News for hackers. Stuff that matters.
Re:Form to DB by _heimdall on Friday February 23, 2024 @07:46AM (#39479872)
React isn't required for client-side validation or non-spec form inputs.

Doing form validation in event handlers for DOM events works very well, and a simple script tag or custom element is all that's needed to build a multi-value select.

Re:Form to DB by throwaway60320 on Friday February 23, 2024 @07:54AM (#39479955)
It's not simple. I made multi-page forms with dozens fields where your suggestion would lead to intangible mess of spaghetti code - I know because I worked with the web way before React. Even with the best coding standards and a team of seniors it's just too hard to maintain - and seniors usually don't write forms.

I really don't want to go back to the jQuery days. You do you, but don't say it's easier - it really isn't.

BTW you can just use Preact if you're worried about the bundle size. I do that, it's perfect and just a little performance impact, usually not visible in small apps.

Re:Form to DB by _heimdall on Friday February 23, 2024 @07:58AM (#39479993)
Oh that's interesting, multi-page forms are actually my least favorite form use case for react.

I reach for a state machine whenever possible to manage the complex flow of the multi-page or multi-step form, even if react is still used for custom inputs.

Re:Form to DB by throwaway60320 on Friday February 23, 2024 @07:59AM (#39480010)
Check out XState, it's really great!

But it's not that necessary in my case, my forms are usually not complex statecharts, just a lot of individual and largely decoupled complex form controls - multiselects with rules, map pins, tag inputs with autosuggest, data grids etc.