Created
September 15, 2016 18:55
-
-
Save panw/0e8c09363cbc97b04d09004fd94975b6 to your computer and use it in GitHub Desktop.
React ES6 Timeline Component
This file contains hidden or 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
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