react-native-otp-inputs icon indicating copy to clipboard operation
react-native-otp-inputs copied to clipboard

Warning: Cannot update a component (`LoginPage`) while rendering a different component (`ForwardRef`). To locate the bad setState() call inside `ForwardRef`, follow the stack trace as described in https://reactjs.org/link/setstate-in-render

Open vigneshkumaran-github opened this issue 2 years ago • 6 comments

When i try to enter numbers im geting this errors

vigneshkumaran-github avatar Nov 16 '23 12:11 vigneshkumaran-github

Yes, Same Problem

ankitthakur34 avatar Jan 05 '24 10:01 ankitthakur34

Yes, Same Problem

tahahaz1374 avatar Jan 05 '24 12:01 tahahaz1374

+1

sami-juvonen avatar Jan 10 '24 09:01 sami-juvonen

+1

eldynguyen1204 avatar Apr 04 '24 02:04 eldynguyen1204

I was able to fix this by wrapping my setState logic in setTimeout function,Here is my code. ` const handleChange = code => { setTimeout(() => { setCode(code); }, 0); };

//and in render <OtpInputs handleChange={handleChange} keyboardType="phone-pad" selectTextOnFocus={false} numberOfInputs={6} inputContainerStyles={{ justifyContent: 'center', flexDirection: 'row', flex: 1, paddingHorizontal: -4, }} inputStyles={{ backgroundColor: '#EDEDED', borderColor: '#D3D3D3', borderWidth: 1, borderStyle: 'solid', flex: 1, margin: 4, height: 52, textAlign: 'center', }} /> `

Hope this helps anyone, till the time it is fixed

yogeshmuli avatar Apr 17 '24 12:04 yogeshmuli

@yogeshmuli could u tell me the reason please , why should i wrap that into setTimeout

vigneshkumaran-github avatar Apr 29 '24 05:04 vigneshkumaran-github