social buttons component for react, includes google, facebook, twitter, pinterest and more
npm install react-social-buttons --save
import ReactDOM from 'react-dom';
import React, { Component, PropTypes } from 'react';
import {
TwitterButton,
FacebookLikeButton,
FacebookShareButton,
FacebookMessengerButton,
GoogleButton,
GoogleHangoutButton,
PinterestButton,
WhatsAppButton,
RedditButton
} from 'react-social-buttons';
class TestComponent extends Component {
isBrowser () {
return !(typeof document === "undefined" || typeof window === "undefined");
}
render () {
let url = ''
if (this.isBrowser()) { url = window.location.href; }
const whatsAppProps = {
msg: 'test',
button: <span>{'Your custom content'}</span>,
};
const redditProps = {
url,
button: <img src={'//www.redditstatic.com/spreddit1.gif'}
alt={'submit to reddit'} border={'0'} />
};
return (
<div id="buttons">
<FacebookLikeButton url={url} />
<FacebookShareButton url={url} />
<FacebookMessengerButton url={url} />
<TwitterButton url={url} text="this page is cool"/>
<GoogleButton url={url} />
<GoogleHangoutButton url={url} />
<PinterestButton url={url} />
<WhatsAppButton {...whatsAppProps} />
<RedditButton {...redditProps} />
</div>
)
}
}
ReactDOM.render( <TestComponent />, document.getElementById('root') )
npm install
npm run build
npm test
npm start