Reputation: 91
Currently have an app with React on the Front end, and Rails on the back end. Want to post stuff to facebook. Any tips for tutorials that I could use?
Upvotes: 2
Views: 5330
Reputation: 927
You can create Facebook Share Button component fair easily by yourself. Just pass the URL you want to share to fb as a param in URL which is provided by Facebook:
`https://facebook.com/sharer/sharer.php?u=${encodedURL}`
I've built a react component for you:
class FBShareButton extends React.Component{
constructor(props){
super(props);
this.state = {
url : this.props.url
}
}
render(){
let encodedURL = encodeURI(this.state.url);
return(
<a href={`https://facebook.com/sharer/sharer.php?u=${encodedURL}`}>Share on Facebook</a>
)
}
}
ReactDOM.render(
<FBShareButton url={"https://stackoverflow.com"} />, document.getElementById('root')
)
Also check the demo here.
Upvotes: 7
Reputation: 3765
React + Facebook + Open Source = here's one option: https://www.npmjs.com/package/react-facebook
Upvotes: 0