Open edwardigates opened 3 years ago
Hi @edwardigates,
We have tested on both Andorid 10 and Android 8, onCodeChanged and onCodeFilled are working as expected.
Hi @ericdao-ttt
I tried to fill the code using useEffect but still the onCodeFilled
is not triggered, am I missing something with my configs?
const [otp, setOtp] = React.useState<string>('')
React.useEffect(() => {
setTimeout( () => setOtp('111111') , 5000)
}, [])
<OTPInputView
pinCount={6}
code = {otp}
editable={true}
autoFocusOnLoad={false}
onCodeChanged = { (code:string) => console.log("new code" + code)}
onCodeFilled = {((code:string) => {
console.log(`Code is ${code}, you are good to go!`)
doLogin(code)
})}
Hi @edwardigates
Can you try to add the ref for the OTPInputView and call ref.current.notifyCodeChanged()
in useEffect
Describe the bug A clear and concise description of what the bug is. I use this library to extract the code from the sms. I also use
useState
hook to save the otp, and I use the otp as a value forOTPInputView
like that:<OTPInputView pinCount={6} code = {otp} onCodeChanged = { (code:string) => console.log("new code" + code)} onCodeFilled = {((code:string) => { console.log(`Code is ${code}, you are good to go!`) doLogin(code) })}/>
After updating, the otp value, I see that the code is filled in the input view, but neither
onCodeChanged nor onCodeFilled
are called. If however I enter the code manually everything work as expected.I tested that on Andorid 10 and Android 8.1.0 in both case it was the same behavior
i have the same problem did you find the solution? any way to workout this Please help?
I have noticed that only one digit is being left to insert while auto-updating the fields. If you write even 1 digit after auto-filling it works. I don't know why is it happening but let's see what happend.
Describe the bug A clear and concise description of what the bug is. I use this library to extract the code from the sms. I also use
useState
hook to save the otp, and I use the otp as a value forOTPInputView
like that:After updating, the otp value, I see that the code is filled in the input view, but neither
onCodeChanged nor onCodeFilled
are called. If however I enter the code manually everything work as expected.I tested that on Andorid 10 and Android 8.1.0 in both case it was the same behavior