shubhanus / otp-input-react

React simple otp input with react hooks
MIT License
59 stars 85 forks source link

ResendOTP refreshes the form. #30

Closed patilkrunal closed 2 years ago

patilkrunal commented 3 years ago

Even adding e.preventDefault it refreshes the page in otp-input-react:v0.2.0 as 0.2.2 had some issues. this is my resendOTP function:


const sendOTP = (e) => {
    e.preventDefault();
    requestOTP({ mobile_no: mobile_no });
    console.log("resend otp clicked");
  };

<ResendOTP
    className="mb-4 mt-2"
    maxTime="30"
    onResendClick={(e) => sendOTP(e)}
  />

Console output is: Uncaught TypeError: e.preventDefault is not a function The button in ResendOTP doesnt have type="button" attribute. Might be because of this. not sure. Its not able to recognize event. How do I solve this issue.

shubhanus commented 2 years ago

Fixed