react-native-picker / picker

Picker is a cross-platform UI component for selecting an item from a list of options.
MIT License
1.5k stars 279 forks source link

TypeError: Cannot read property 'props' of undefined #495

Open alifa20 opened 1 year ago

alifa20 commented 1 year ago

We are using React Native for both our iOS and Android applications. Our production alerting system has detected an error, TypeError: Cannot read property 'props' of undefined. It only happens on the Android platform. Upon further investigation and analyzing the Hermes build, we have identified the source of the error to be the "onSelect" function.

While we have been unable to replicate the issue ourselves, we came across a fork in the repository where someone has independently provided a fix for it. You can find the fix here: https://github.com/react-native-picker/picker/compare/master...Kraudia:picker:master

It seems that incorporating this fix into our forked version of the package may resolve the problem. We plan to apply this change as a "patch package" in our codebase and closely monitor our alerting system for any further occurrences. This is the code we have in case it gives any clues:

    <Picker testID='picker' onValueChange={onValueChangeWrapper} selectedValue={props.selectedValue}>
      {props.items.map((item) => (
        <Picker.Item key={item.value} label={item.label} value={item.value} enabled={item.disabled || true} />
      ))}
    </Picker>

We would greatly appreciate any insights you can provide regarding the potential causes of this issue. This will assist us in reproducing the error for our QA team. Additionally, I would like to hear your thoughts on whether forked version should be applied for the new package release of react-native-picker?

Thanks again for all the hard work guys!