React-Custom-Hooks-Form-Validation
React-Custom-Hooks-Form-Validation copied to clipboard
Allow for arbitrary fields and improve reuse
I really quite enjoyed this video Matt! I'm an experienced front end developer but still leveling up my React :) This was a fun exercise!
Next Riot left an interesting comment on the youtube video and I became obsessed with how I could refactor this to achieve that (self inflicted homework haha!)
My idea was mostly correct (I commented back to him as you see) and here's the implementation.
I'm not sure how every single field type could/work as I think there is a coupling against the name attribute, but I'm sure you could always use a data-attr or something if that became an issue in a later iteration.
Here are the relevant spot checks:


Nominal success case:

The logging you see ^ was remove in one of the later commits so it won't happen if you happen to pull down and run yourself.
Bonus: fixed some missing code when you leave email blank it wasn't throwing an error 🙌 😋