react-facebook icon indicating copy to clipboard operation
react-facebook copied to clipboard

Share Callback not working

Open lampt2010 opened this issue 6 years ago • 4 comments

this is my code <FacebookProvider appId="key"> <Share href="http://www.facebook.com" onResponse={this.handleResponse} onError={this.handleError}> {({ handleClick, loading,error,data }) => ( <button type="button" disabled={loading} onClick={handleClick} >Share</button> )} </Share> </FacebookProvider> After y share post, handleResponse fuction not called . If I cancel share , I get error Untitled

Who can demo help me resolve this problem

lampt2010 avatar Aug 15 '19 05:08 lampt2010

yes, i would be interested in seeing how this works. Or with the Feed option.

MildTomato avatar Aug 24 '19 11:08 MildTomato

export default class SocialShare extends Component {

  handleResponse = (data) => {
    console.log(data);
  }

  handleError = (error) => {
    console.log(error);
  }

    render() {
        return (
              <FacebookProvider appId="436255920314257">
                <Feed link="https://www.facebook.com" onCompleted={this.handleResponse} onError={this.handleError}>
          {({ handleClick }) => (
            <button type="button" onClick={handleClick}>Share on Feed</button>
          )}
        </Feed>
      </FacebookProvider>  
   }
}

I would of thought the above would of worked for Share Button and Feed Button

Screenshot 2019-08-24 at 20 06 32

I get the following error when closing the dialog box

MildTomato avatar Aug 24 '19 12:08 MildTomato

Hi, I am also facing the same issue with share button. I've even tried giving user_posts permission to my test user for my app.

ghost avatar Aug 30 '19 15:08 ghost

handleClick = (caption) => { var hours = 24; // Reset when storage is more than 24hours var now = new Date().getTime(); var setupTime = localStorage.getItem('setupTime'); if ((now - setupTime > hours * 60 * 60 * 1000) || !setupTime) { localStorage.removeItem('CURRENT_USER'); localStorage.removeItem('setupTime'); this.props.actShowLoginFb(); } else { //SDK loaded, initialize it window.FB.init({ appId: AppConstants.FACEBOOK_APPID, xfbml: true, version: 'v2.6' }); const props = this.props.item; const th = this; //JS SDK initialized, now you can use it window.FB.ui({ method: 'share', title: 'Title Goes here', description: '. ', href: caption, }, function (response) { if (response && !response.error_code) { th.props.actSharedSuccess(props.id).then(() => { }); } else { } }); //load the JavaScript SDK (function (d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) { return; } js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/sdk.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); } } this is my code. Hoping to resolve y . But this sharing doesn't display image and title share because my project is client side !

lampt2010 avatar Oct 07 '19 02:10 lampt2010