constsubmitHandler=event=>{event.preventDefault();constformData=newFormData(event.currentTarget);// You can send formData to the back-end using fetch.// It arrives there as an object { data1: value1, data2: value2, data3: value3 }};constMyComponent=()=>(<formonSubmit={submitHandler}><inputname="data1"/><inputname="data2"/><inputname="data3"/><buttontype="submit">submit</button></form>);
The good thing about using the platform that way, is that you can transfer that knowledge anywhere, not just React. You can literally use that same submitHandler in every library or framework out there (the philosophy that Remix has).
Software engineer, architect, consultant, amateur UI/UX designer, computer enthusiast, gamer. Often coming up with ideas and thoughts that I then write into a post within the next 60 minutes.
It can be improved a little bit using
FormData:The good thing about using the platform that way, is that you can transfer that knowledge anywhere, not just React. You can literally use that same
submitHandlerin every library or framework out there (the philosophy that Remix has).Cheers!
I always prefer this over controlled inputs. Less code, better performance.