seeden / react-facebook

Facebook components like a Login button, Like, Share, Chat, Comments, Page or Embedded Post
MIT License
790 stars 144 forks source link

Sharing Programmatically #86

Closed Irrelon closed 6 years ago

Irrelon commented 6 years ago

Thanks for your work on this library!

Quick question, how do we open a share dialog programmatically? I know we can include the FB api library directly but I guess that's a bit wasteful when it is already being included here.

Something like:

import FacebookProvider from 'react-facebook';

...
render () { return (
<FacebookProvider appId="12345" ref={(elem) => {this.fbProvider = elem;}} />
) };
...

openShare () {
   this.fbProvider.share(url);
}

Is there a way to access the FB api directly through this library or a way to programmatically open a share dialog? If not, what is your recommended way to do this (use FB api directly etc)?

Many thanks!

seeden commented 6 years ago

use <Share or <ShareButton component