lawnstarter / react-native-picker-select

🔽 A Picker component for React Native which emulates the native <select> interfaces for iOS and Android
https://npmjs.com/package/react-native-picker-select
MIT License
1.74k stars 497 forks source link

Crashing App on Android - React Navigation v5 & useNativeDriver #442

Open ebykdrms opened 3 years ago

ebykdrms commented 3 years ago

First of all, I may not be able to express myself properly because my English is not good but i will try.

Describe the bug
I am using react-navigation v5. As you know, it keeps screen status for we can go to same page second times.
I use { useNativeDriver: true }
in Animated.event()
in onScroll event in Animated.ScrollView component in a stack screen.
This is only an example. There is same problem any pages what it is using useNativeDriver:true.
If i visit this screen and after then press any RNPickerSelect, my app is crashing. But if i don't visit this screen, RNPickerSelect is works normally.
It is enough to visit this page only once. To Reproduce
If i change status of useNativeDriver value to false, RNPickerSelect works fine. But this time, my animations work badly. I can't do this on my project.

Expected behavior
n/a

Screenshots
n/a

Additional details

Reproduction and/or code sample
n/a

abdbodara commented 3 years ago

Same here

ejilee commented 3 years ago

I saw a similar issue with another picker library, (Android crashing upon touch event on picker component) here. Checkout Rapomon's workaround. Seems to work for this library too. The gist is to put an absolutely positioned empty Text element on top of the picker component.

Here's how my code looks :

<View style={{ flex : 1 }}>
    <RNPickerSelect
        items={myItems}
        value={myValue}
        placeholder={myPlaceholder}
        onValueChange={myChangeHandler}
    />
    <Text
        style={{
            width: '100%',
            height: '100%',
            position: 'absolute',
            bottom: 0,
            left: 0,
        }}>
        {' '}
    </Text>
</View>
iYahya commented 3 years ago

you could use this solution here https://github.com/react-native-picker/picker/issues/225#issuecomment-851495915

Reginaldo1239 commented 3 years ago

@ejilee thanks

SLMohitMathur commented 3 years ago

I saw a similar issue with another picker library, (Android crashing upon touch event on picker component) here. Checkout Rapomon's workaround. Seems to work for this library too. The gist is to put an absolutely positioned empty Text element on top of the picker component.

Here's how my code looks :

<View style={{ flex : 1 }}>
    <RNPickerSelect
        items={myItems}
        value={myValue}
        placeholder={myPlaceholder}
        onValueChange={myChangeHandler}
    />
    <Text
        style={{
            width: '100%',
            height: '100%',
            position: 'absolute',
            bottom: 0,
            left: 0,
        }}>
        {' '}
    </Text>
</View>

Thanks, working for me too