K
K
Kentavr162021-05-29 20:44:37
React
Kentavr16, 2021-05-29 20:44:37

How to handle onSubmit event of form element in React using hooks?

The question has actually been asked. There are examples on the Internet of how to implement this using typescript, but I did not find it in simple Java.

const handleSubmit = КАК ЭТО ОБРАБОТАТЬ?

  };
  return (
    <form onSubmit={handleSubmit}>
      <div>
        <label htmlFor='email'>Email</label>
        <input type='email' id='email' value={email} onChange={(e) => setEmail(e.target.value)} />
      </div>
      <div>
        <label htmlFor='password'>Password</label>
        <input type='password' id='password' value={password} onChange={(e) => setPassword(e.target.value)} />
      </div>
    </form>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kentavr16, 2021-05-29
@Kentavr16

The solution was found - a custom hook useForm. Does a great job and simplifies form processing.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question