Banner Image

How to use share API in react native

Dashrath Singh
April 27, 2022
0 Minutes Read

scroll

down

Banner Image

Looking for other services or solutions?

ux/ui image
Explore our services

IN a nutshell

For the other options, refer to the docs

 https://react-native-share.github.io/react-native-share/docs/share-open

IN a nutshell

Use of view shot with share

https://www.gkmit.co/blog/mobile-development/capture-and-share-screenshot-in-react-native

Overview

How to use share API in react native

  • First install the community package known as react-native-share

command: yarn add react-native-share

  •  keep mind that React-native-share is promise based. So  so you can use async await or use then,catch
  • Now simply import it and use it
import Share from 'react-native-share';

Share.open(options)

  .then((res) => {

    console.log(res);

  })

  .catch((err) => {

    err && console.log(err);

  });

Here urlString is a image path returned from view-shot plugin.

Title: the title you want in whatsapp message. Usually not required.

Message: the message u want to use on sharing the image.

Resources:

 

 

 

0 Shares
Tweet
Share
Share
Pin