devfolioco / react-otp-input

:heavy_check_mark: OTP Input Component for React
http://devfolioco.github.io/react-otp-input
MIT License
643 stars 423 forks source link

Autofocus not working when state and setState is passed from the parent #441

Open YashChauhan858 opened 4 months ago

YashChauhan858 commented 4 months ago

Auto focus is not working when i passs the state and setState from the parent component but it works when it is internal to the component.

export default function OTP({ setOtp, otp }) { // const [otp, setOtp] = useState('')

return ( <OtpInput value={otp} onChange={setOtp} numInputs={4} inputStyle={'otp_input'} renderSeparator={-} renderInput={(props) => <input {...props} />} /> ) }