peacechen / react-native-modal-selector

A cross-platform (iOS / Android), selector/picker component for React Native that is highly customizable and supports sections.
MIT License
369 stars 129 forks source link

How to use getSelectedItem() method #134

Closed Jacob-o closed 4 years ago

Jacob-o commented 4 years ago

How do I use the getSelectedItem() method? Thanks so much!

peacechen commented 4 years ago

You'll need a ref to the modal selector. Documentation and examples on refs: https://reactnative.dev/docs/direct-manipulation https://medium.com/@payalmaniyar/deep-understanding-of-ref-direct-manipulation-in-react-native-e89726ddb78e

However I would not recommend using getSelectedItem() unless you have a unique use case and no other option. The onChange callback prop fires when the user has selected an item. You could store that value in your component's state for use later. https://github.com/peacechen/react-native-modal-selector#props