r/reactjs • u/Last_Distribution_84 • Dec 17 '23
Discussion Is react hook form overhyped?
I created a custom form validation hook.Its a simple hook and I felt I didn't needed react hook forms for just simple form validation. For simpe validation writing that much code and loading the whole library felt not right. Maybe I am wrong.
0
Upvotes
1
u/[deleted] Dec 17 '23
Mobx, mobx-react, and mobx forms is my preferred stack on react, but rhf is pretty decent.
I have a big problem with react hook forms design pholosophy and I dont like it.
For example, if I have a DateTime from luxon2 on an object and I want to bind it to a react hook useForms default values and rely on uts toJson and json parse abilities, react hook form rips it all off . React hook forms will remive to toJson override on DateTime and cause it to not serialize properly. So when the forns submitted the entire DateTime object is serialized instead of just the iso date string....
I do not like such a strongly opinionated library dictating how I use it.
This requires me to use date strings on all my rhf models, so I have to use DateTime all over the place, lots of time zone bugs get inteoduced...
I like to create a class that instatiates itself from api responses so my dates are DateTimes in the class, and the logic is in one place.
React hook forms makes me maintain different sets of models. So we have "form models" and we can instantiate those from api models... Its more to maintain.