Skip to content

Instantly share code, notes, and snippets.

@panw
Created September 15, 2016 18:55
Show Gist options
  • Save panw/0e8c09363cbc97b04d09004fd94975b6 to your computer and use it in GitHub Desktop.
Save panw/0e8c09363cbc97b04d09004fd94975b6 to your computer and use it in GitHub Desktop.
React ES6 Timeline Component
class Timeline extends React.Component {
constructor(props) {
super(props);
this.state = {
tweets: []
};
this.fetchTweets = this.fetchTweets.bind(this);
}
componentDidMount() {
this.fetchTweets();
}
fetchTweets() {
$.ajax({
url: '/tweets/recent',
method: 'GET'
})
.done((response) => {
this.setState({
tweets: response
})
})
}
render() {
return (
<section>
<ul>
<Tweet />
</ul>
</section>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment