reading-notes

Aloysious' Codefellows Reading Notes

View the Project on GitHub

Code 301 Reading Notes

Class 04

<== Previous Lesson Next Lesson ==>

<== Home 🏠

React and Forms

letting the browser handle the state:

export function LoginForm() {
  const handleSubmit = (e: React.FormEvent) => {
    e.preventDefault();
    const formData = new FormData(e.target as HTMLFormElement);
    api.login(formData.get('email'), formData.get('password'));
  };
  return (
    <form onSubmit={handleSubmit}>
      <div>
        <label htmlFor="email">Email</label>
        <input
          type="email"
          id="email"
          name="email"
        />
      </div>
      <div>
        <label htmlFor="password">Password</label>
        <input
          type="password"
          id="password"
          name="password"
        />
      </div>
      <button>Log in</button>
    </form>
  );
}

// Not a single Hook in sight, no setting the value, and no change listeners either. 





// https://blog.logrocket.com/forms-in-react-in-2020/

React Docs - Forms

React Bootstrap - Forms

Reading

Bookmark/Skim

<== Home 🏠