Created
June 26, 2023 04:06
-
-
Save maskaravivek/590d2d55f72da2f9a3bd150d579ff361 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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