Hacker News new | ask | show | jobs
by arvinsim 2234 days ago
> And it makes it harder to do so. I hate doing forms in React. You basically have to reinvent the plumbing that's already standard with the HTML spec. Very tedious.

Show me the HTML standard that supports SPA submissions that don't reload the page.

It seems that your problem is about SPAs, not React.

1 comments

>Show me the HTML standard that supports SPA submissions that don't reload the page.

Any HTML form that uses a standard button element rather than a submit button. Attach a JS event listener to it, read the form, post by AJAX.

That was a thing long before React came along.

That was a thing even before AJAX came along, eg via forms targetting an iframe.

A long time ago, I wrote a single-page chat application that continuously updated through chunked transfers, with submission via a plain old HTML form that received a 204 response.

You can actually do that with React. Nothing is stopping you.

It's not the recommended way because as soon as you want validation or dynamic fields you need state anyway.

And there're easy libraries like Formik that handle all the annoyances for you (although taking you away from raw HTML at the same time).

Do you miss punch-cards too?

Of course you can do that with React. GP implied that it was impossible without React, because standard HTML didn't support it, but wasn't correct.

There may be plenty of advantages to using React but it isn't necessary for "SPA submissions that don't reload the page."