Skip to content

Instantly share code, notes, and snippets.

@jwo
Created October 21, 2015 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwo/9c017c4874d686a9e3e9 to your computer and use it in GitHub Desktop.
Save jwo/9c017c4874d686a9e3e9 to your computer and use it in GitHub Desktop.
var Taylor = React.createClass({
getInitialState() {
return {
urls: []
};
},
componentDidMount() {
var component = this;
fetch("http://api.giphy.com/v1/gifs/search?q=taylor+swift&api_key=dc6zaTOxFJmzC").then(function(response) {
response.json().then(function(data) {
component.setState({
urls: data.data
});
});
});
},
render() {
return <div id="images"> {
this.state.urls.map(function(image) {
return <img src={image.images.fixed_height.url}></img>
})
}
</div>
}
});
React.render( <Taylor/> , document.body);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment