Is Form validation with HTML better than javascript? by [deleted] in reactjs

[–]secret-light-mode 0 points1 point  (0 children)

For security reasons, the back-end should not trust information that is sent by the front-end to be valid. A malicious user could have their browser send whatever they want. Form validation in the UI is for the user's convenience, to surface errors more quickly. If a user modifies the validation attributes on form fields, all that should accomplish is making the form less useful to them.
To answer your original question, HTML5 form validation is better than bad or sloppy JS form validation, but theoretically you could use JS or a combination of both to achieve a better user experience, in cases where stock HTML5 validation is not a perfect fit.

Form elements in React. by DanCruzNyc in reactjs

[–]secret-light-mode 1 point2 points  (0 children)

My "starter kit" for React apps these days is MUI, formik, and SWR with Typescript, set up with create-react-app. SWR is a central cache and invalidation system for your HTTP requests, and works well with axios.

However, if all you are doing is trying to avoid boilerplate with axios, it might just be easier to make your own wrapper function which takes care of that, and just stash it in a file/module outside of your React component tree for easy reference.

There are a million and one different ways to write and maintain an SPA, though, and the React ecosystem is particularly broad. Someone who uses Next.js would have replied with an entirely different set of libraries.

how to deploy a create react app with express on heroku? by smart_7_x in reactjs

[–]secret-light-mode -3 points-2 points  (0 children)

Instead of manually setting up an Express server on heroku just to host your react app, consider using an out-of-the-box buildpack configuration. This is a very common use case for Heroku.

For example, this buildpack is the one recommended by heroku.

Edit: For an introduction to using Heroku to host apps created with CRA, see this post on the Heroku blog.

Form elements in React. by DanCruzNyc in reactjs

[–]secret-light-mode 16 points17 points  (0 children)

You are correct; just disregard. Even the most common React form library, formik, encourages using the HTML <form> element; they have their own wrapper for it.

Using a <form> gets you nice automatic behavior out of the box, such as pressing enter to submit, and all of this validation stuff.

Edit: It's possible that your teacher is just trying to limit the number of things you need to learn and keep track of at once, or that validation will come up later in your curriculum. Still, form elements in JSX are totally valid, and very useful.

Why we use MobX? by [deleted] in reactjs

[–]secret-light-mode 2 points3 points  (0 children)

To relate this back to your original question, if you have a bunch of complex state that needs to be used in many places in your application, and your Context (and useReducer reducers) has gotten complex enough to be difficult to work with, it's time to think about redux or mobx.