onSubmit does not allow a function call?

30 Views Asked by At

So here is my code for that part which is correct, by the way:

function Form() {
   const [text, setText] = useState("");
   function handleSubmission(e) {
      e.preventDefault();
   }

   return (
      <form className="the-form" onSubmit={handleSubmission}>
       ....

My question is, why can I write onSubmit={handleSubmission()} instead? I thought that function is called whenever a submission is made?

Edit: So this question is about asking why we have to pass the name of the function in the onSubmit attribute, rather than making a function call in it.

0

There are 0 best solutions below