Calling **`this.mobile(this.state.number)`** function will cause a loop of 10-12 iterations of the `alert()`
Can you explain me please why ?
checkNum = () => {
const submit = document.getElementById('mySubmit');
submit.addEventListener('keyup', (event) => {
if (event.key === 'Enter' && this.mobile(this.state.number))
//calling from here
{
this.setState({ mobileNum: this.state.number });
}
});
};
mobile = (e) => {
let num = /^0(5[^7]|[2-4]|[8-9]|7[0-9])[0-9]{7}$/;
const isRight = num.test(e);
alert(`The number you've entered is ${isRight}`);
return isRight;
};
Thanks
Aucun commentaire:
Enregistrer un commentaire