V
V
Vann Damm2020-06-04 15:06:42
JavaScript
Vann Damm, 2020-06-04 15:06:42

onClick event only fires after two clicks?

There is such input

<input name={email} onClick={onEmailClick} onChange={setMail} />

and such a handler that works after two clicks on the input. How to make it work on the first click?
const onEmailClick = (e) => {
    e.preventDefault()
    onEmailClickedSet(true);
  };

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
uRoot, 2020-06-04
@uroot

You have some mess: onClick={onEmailClick} onChange={setMail}
Why two handlers for one input? Why is it not specified what type of input you have?
The onClick event fires on every click, not after two.
Wang that the onChange event changes something and onClick works as you need only after this change, i.e. from the second time.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question