sohobloo / react-native-modal-dropdown

A react-native dropdown/picker/selector component for both Android & iOS.
MIT License
1.19k stars 477 forks source link

React Native's Share API does not work with onSelect #198

Open Lumpell opened 6 years ago

Lumpell commented 6 years ago

I want to pull up the share api when one of the items in a dropdown is selected. I have a simple method that I'm calling to handle that. The method works just fine, however for some reason the Share dialog does not appear. Any ideas?

Image: screen shot 2018-10-08 at 5 03 07 pm

Code (as applicable):

    handleIconSelect(index) {
        if (index == 0) {
            this.toggleFavoritesOnPress();
        }
        else if (index == 1) {
            Share.share({
                message: 'A framework for building native apps using React',
                url: 'http://facebook.github.io/react-native/',
                title: 'React Native'
              }, {
                dialogTitle: 'Share React Native website',
                excludedActivityTypes: [
                  'com.apple.UIKit.activity.PostToTwitter'
                ],
                tintColor: 'green'
              })
              .then(this._showResult)
              .catch((error) => this.setState({result: 'error: ' + error.message}));
        }
    }

     shareItem = <Text>{ shareContent } Share</Text>`

     <ModalDropdown 
         options={[shareItem, shareItem, 'recommend']}
         onSelect={(index) => {this.handleIconSelect(index)}}
     >
         {moreList}
     </ModalDropdown>
bastiRe commented 6 years ago

This seems to be related to #98 . There seems to be a conflict with the animations. It works reliably for me when I set animated={false} on the modal and wrap the shareDialog in a setTimeout.