React Native 共享视图作为图像

React Native Share View as An Image

我想在 React Native 中以图像形式分享我的观点。例如,这是我的观点:

<View>
    <Image source={require('myImage.png')}/>
    <Text> My Text </Text>
</View>

有没有办法像这样像短信一样分享:

async shareMyMessage() {
    try {
        await Share.share({
            message: 'It is my message'
        });
    }
    catch(error) {}
}

我应该先把它们画在类似“Canvas”的东西上然后分享结果吗?如果是,如何? 或者有更简单的方法吗?

它可以看起来像这样:

captureRef(viewRef, {format: "png", quality: 0.8, result: "base64"}).then(base64Data => {
      const base64Data = `data:image/png;base64,` + base64Data;

      Share.open({ url: base64Data })
});

截图:https://www.npmjs.com/package/react-native-view-shot

分享:https://www.npmjs.com/package/react-native-share