0

I am trying to make use of react-otp-input package by disabling the OTP input for 5 seconds if the OTP input value is reached. The issue I encounter is that the state does not get properly updated. I have prepared a Codesandbox example, which shows that the otp length is not calculated properly when you start deleting characters and is one state behind. What might cause this issue?

Codesandox link: https://codesandbox.io/s/dazzling-rhodes-klqyhp?file=/src/App.js

Updated: This can not be placed in the useEffect hook, as the setInterval function never counts down!

Aleksandrs
  • 81
  • 6

0 Answers0