I have a client side rendered react app. I want to display a facebook send button on my page.
The instructions given on the developer page do not tell me how to do it
https://developers.facebook.com/docs/plugins/send-button#configurator
Plus, I did not find an npm compatible package released by facebook for their SDK. So how does one go about including the SDK in a react app?
EDIT: I tried using some async loader in react.
import React, { Component } from 'react';
import scriptLoader from 'react-async-script-loader';
@scriptLoader(
'https://connect.facebook.net/es_ES/sdk.js#xfbml=1&version=v2.5',
)
class FacebookSendButton extends Component {
componentDidMount() {
const { isScriptLoaded, isScriptLoadSucceed } = this.props;
if (isScriptLoaded && isScriptLoadSucceed) {
console.log('script load success from didMount');
}
}
componentWillReceiveProps({ isScriptLoaded, isScriptLoadSucceed }) {
if (isScriptLoaded && !this.props.isScriptLoaded) { // load finished
if (isScriptLoadSucceed) {
console.log('script load success from receiveProps');
}
}
}
render() {
return (
<div>
BEFORE FB ROOT.
<div className="fb-send"
dataHref="http://www.your-domain.com/your-page.html"
dataLt ayout="button_count"
/>
<div id="fb-root"></div>
</div>
);
}
}
export default FacebookSendButton;
This does not render a facebook send button.