import React, { useEffect } from "react"; export default function Otp({handleChange, value}) { useEffect(() => { const otp = document.querySelector("#otp-inputs"); // eslint-disable-next-line no-restricted-syntax for (const pin of otp.children) { // eslint-disable-next-line no-loop-func pin.onkeyup = (value) => { if(pin.children){ if(value.key === '' || value.key === ' ' || value.key === 'ArrowRight' || value.key === 'ArrowLeft' || value.key === 'ArrowUp' || value.key === 'ArrowDown' || value.key === 'Tab') return; if(value.key === 'Backspace'){ if(pin.previousSibling){ pin.previousSibling.children.otp.focus(); } else {return;} } else { pin.nextSibling.children.otp.focus(); } } }; } }, []); return ( <>