-
-
Save kjvenky/7cee69d4b8e5dc6d12526198b9bd808f to your computer and use it in GitHub Desktop.
React Component Implementing the Linkedin Javascript SDK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var React = require('react'); | |
var LinkedinLogin = React.createClass({ | |
componentDidMount: function() { | |
var liRoot = document.createElement('div'); | |
liRoot.id = 'linkedin-root'; | |
document.body.appendChild(liRoot); | |
(function(d, s, id) { | |
const element = d.getElementsByTagName(s)[0]; | |
const ljs = element; | |
var js = element; | |
if (d.getElementById(id)) { | |
return; } | |
js = d.createElement(s); | |
js.id = id; | |
js.src = '//platform.linkedin.com/in.js'; | |
js.text = 'api_key: [YOUR_API_KEY]'; | |
ljs.parentNode.insertBefore(js, ljs); | |
}(document, 'script', 'linkedin-sdk')); | |
}, | |
callbackFunction: function() { | |
IN.API.Profile("me").result(function(r) { | |
console.log(r); | |
}); | |
}, | |
handleClick: function(e) { | |
e.preventDefault(); | |
IN.User.authorize(this.callbackFunction, ''); | |
}, | |
render: function() { | |
return ( | |
< div > | |
< button onClick = { this.handleClick } | |
className = { "button social " + this.props.name.toLowerCase() + " " + this.props.visibility } > { this.props.text } < i className = { "fi-social-" + this.props.name.toLowerCase() } | |
/></button > | |
< /div> | |
); | |
} | |
}); | |
module.exports = LinkedinLogin; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment