Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save maskaravivek/590d2d55f72da2f9a3bd150d579ff361 to your computer and use it in GitHub Desktop.
Save maskaravivek/590d2d55f72da2f9a3bd150d579ff361 to your computer and use it in GitHub Desktop.
// add following imports at the top
import Share from "react-native-share";
import RNFS from "react-native-fs";
const captureAndShareScreenshot = () => {
if (!ref || !ref.current) {
return;
}
ref.current.capture().then((uri: any) => {
RNFS.readFile(uri, "base64").then((res) => {
let urlString = "data:image/jpeg;base64," + res;
let options = {
title: "Share Title",
message: "Share Message",
url: urlString,
type: "image/jpeg",
};
Share.open(options)
.then((res) => {
console.log(res);
})
.catch((err) => {
err && console.log(err);
});
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment