forked from davidchang/yo-in-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
code-snippet
34 lines (29 loc) · 971 Bytes
/
code-snippet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import ReactDOM from 'react-dom';
import React from 'react';
class AppComponent extends React.Component {
render() {
return (
<a href='https://twitter.com/share' className='twitter-share-button' ref='share' data-url='https://twitter.com/'>Tweet</a>
);
}
onClick() {
console.log("Clicked");
}
componentDidMount() {
window.twttr.events.bind('click', this.onClick);
}
}
//index.html below
ReactDOM.render(<AppComponent />, document.getElementById('app'));
<!doctype html>
<html>
<head>
<title>Twitter Share</title>
</head>
<body>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');
</script>
<div id="app"></div>
<script type="text/javascript" src="assets/app.js"></script>
</body>
</html>