react-native - React Native共享方法多窗口

标签 react-native

我正在使用 React Native Share 来共享文本内容。问题是多次单击共享按钮后会相互打开多个窗口。即使我禁用了共享点击按钮,但它也没有用。

标准方法是,如果共享窗口已打开,则再次单击共享按钮时窗口将关闭。怎么办?

<Button 
 transparent
 disabled={this.state.isShareDisabled}
  onPress={() => this.onShare()}>

onShare() {
    if(!this.state.isShareDisabled)
    {
    this.setState(
        {
            isShareDisabled:true
        }
    )
    Share.share({
      message: “Message test”,
      url: ”www.google.com”,
      title: “Title test”
    }, {
      // Android only:
      dialogTitle: 'Share',
      // iOS only:
      excludedActivityTypes: [
        'com.apple.UIKit.activity.PostToTwitter'
      ]
    }) .then((result) => {
        this.setState(
            {
                isShareDisabled: false,
            }
        )
    })
}
  }

最佳答案

使用驳回操作。分享事件在 Android 和 iOS 上均支持。

关于react-native - React Native共享方法多窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49046409/

相关文章:

javascript - 如何通过 react-navigation 在 react-native 上使用 react 钩子(Hook)

javascript - 错误边界应该实现 getDerivedStateFromError()

react-native - undefined 不是对象(评估 'object.keys(routeConfigs)' )

javascript - react-native: undefined 不是带有 react 导航的对象(评估 '_this2.props.navigation')

react-native - 如何在 native react 中的 flatList 中显示网格线

javascript - react native : How to render check box inside flatlist

javascript - 在 native react 中使用 "for await...of"

javascript - react-native FlatList 的 RenderFeed 函数 - 错误 : Objects are not valid as a React child

reactjs - 向上拖动 ScrollView,然后在 React Native 中继续滚动

react-native - React Native 漏斗图