I am just writing to text input and in onChange
event i call setState
, so React rerenders my UI. The problem is that the text input always lose a f
included the next code in tag input:
ref={(input) => {
if (input) {
input.focus();
}
}}
Before:
validEmail(e.target.value)}
/>
After:
{
if (input) {
input.focus();
}
}}
defaultValue={email}
className="form-control"
type="email"
id="email"
name="email"
placeholder={"mail@mail.com"}
maxLength="15"
onChange={(e) => validEmail(e.target.value)}
/>