I have built an application where I want to share a component as an image. I am doing it like so.
const shareImageHandler = async () => {
try {
const uri = await captureRef(containerRef, {
quality: 1,
format: "jpg",
});
await Sharing.shareAsync(uri);
console.log("action succeed");
} catch (error) {
console.log("something went wrong!");
}
};
But I am getting this error.
[TypeError: undefined is not an object (evaluating '_expoSharing.default.shareAsync')]
the component that I want to share as an image.
<ImageBackground
ref={containerRef}
source={{ uri: imgUrl ?? img() }}
resizeMode="cover"
style={styles.bgImg}
>
<View
style={{
width: "100%",
height: "100%",
position: "absolute",
top: 0,
left: 0,
backgroundColor: "rgba(0,0,0,.7)",
}}
/>
<View style={styles.contentContainer}>
<Text style={styles.quote}>“ {content} ”</Text>
<Text style={styles.author}>—{data}</Text>
</View>
</ImageBackground>
I have tried many solutions but no one did the trick.
Note: I am able to save the component as an image in the gallery successfully, It is just a side note.
This application will be used only for android devices.
Thanks In advance.