Skip to content

Instantly share code, notes, and snippets.

@JamesTheHacker
Last active April 3, 2018 09:20
Show Gist options
  • Save JamesTheHacker/09ed5809fd80e22bda5678baeac5d014 to your computer and use it in GitHub Desktop.
Save JamesTheHacker/09ed5809fd80e22bda5678baeac5d014 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react'
import { Meteor } from 'meteor/meteor';
import PropTypes from 'prop-types'
class FacebookLoginButton extends Component {
static propTypes = {
label: PropTypes.string,
onError: PropTypes.func,
onSuccess: PropTypes.func,
permissions: PropTypes.array,
}
static defaultProps = {
label: 'Login',
onError: () => {},
onSuccess: () => {},
permissions: [ 'public_profile', 'email' ]
}
handleClick = () => {
Meteor.loginWithFacebook(
{ requestPermissions: this.props.permissions },
err => {
if (err) return this.props.onError(err)
return this.props.onSuccess()
}
)
}
render() {
return (
<button onClick={this.handleClick}>
{this.props.label}
</button>
)
}
}
export default FacebookLoginButton
import React from 'react'
import FacebookLogin from '../components/FacebookLoginButton.js'
export default () =>
<div>
<h1>Homepage</h1>
<FacebookLogin />
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment