Closed osvaldokalvaitir closed 3 years ago
Seems like the Android picker crashes if your selectedValue is not part of the Picker.Items. Try
const [selectedLanguage, setSelectedLanguage] = useState(null);
if I'm not mistaken, I thought about it and tested it! but i will test again
Hi, the same thing has been happening to me as well on Android, just noticed it yesterday. My implementation is similar to that of @osvaldokalvaitir
import { Picker } from '@react-native-picker/picker';
const [selectedLanguage, setSelectedLanguage] = useState(-1);
<Picker
selectedValue={selectedLanguage}
onValueChange={value => { setSelectedLanguage(value) }}
>
<Picker.Item label="None" value={-1} />
<Picker.Item label="Test 1" value={0} />
<Picker.Item label="Test 2" value={1} />
</Picker>
The app just crashes and I get no error when this happens.
I use react native 0.64.1 and react-native-picker 1.16.3
[Edit]
Just to add I used the adb logcat to see what happens when it crashes, here's the log.
07-16 10:16:29.166 10501 10501 E AndroidRuntime: Process: com.myawesomeapp, PID: 10501
07-16 10:16:29.173 1712 2201 W ActivityManager: Force finishing activity com.myawesomeapp/.MainActivity
07-16 10:16:29.684 1712 1726 W ActivityManager: Activity pause timeout for ActivityRecord{6ebc1ca u0 com.myawesomeapp/.MainActivity t166 f}
07-16 10:16:40.328 1712 1726 W ActivityManager: Activity destroy timeout for ActivityRecord{6ebc1ca u0 com.myawesomeapp/.MainActivity t166 f}
07-16 10:16:40.361 1348 1393 E BufferQueueProducer: [com.myawesomeapp/com.myawesomeapp.MainActivity] queueBuffer: BufferQueue has been abandoned
07-16 10:16:40.361 1348 1364 E BufferQueueProducer: [com.myawesomeapp/com.myawesomeapp.MainActivity] dequeueBuffer: BufferQueue has been abandoned
07-16 10:17:16.650 1712 2201 I ActivityManager: Killing 10501:com.myawesomeapp/u0a99 (adj 900): crash
I used this terminal command adb logcat | grep 'myawesomeapp'
Not sure if this helps.
Hi @osvaldokalvaitir, I found the cause of the issue, it's our RN version, seems the issue was actually with react native, after updating from 0.64.1 to 0.64.2 the problem went away. See this issue it's similar to this one. https://github.com/react-native-picker/picker/issues/271
@thecodecafe Hi, sorry for the delay, I won't be able to test it, I made my own component, so I will close the issue and test it in the future. Thanks.
My app closes when I click the first time to open the modal, I'm using Android and I just made a new project with react-native 0.64.1 and @react-native-picker/picker 1.16.1.
The code that happens the error is simple, almost like the example: