Created
April 29, 2015 14:45
-
-
Save karlbright/663849826406bc0a2966 to your computer and use it in GitHub Desktop.
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
import React from 'react' | |
import {Link, State} from 'react-router' | |
import Superagent from 'superagent' | |
// <RepoDetail name='collabtracks' author='karlbright' /> | |
class RepoDetail extends React.Component { | |
componentWillMount() { | |
this.loadDetails(this.props.author, this.props.name); | |
} | |
componentWillReceiveProps() { | |
this.loadDetails(this.props.author, this.props.name); | |
} | |
loadDetails(author, name) { | |
Superagent.get(`https://api.github.com/repos/${author}/${name}`) | |
.send() | |
.end((error, response) => { | |
this.setState({ repo: response.body }); | |
}); | |
} | |
render() { | |
if(!this.state.repo) return null; | |
return ( | |
<div className="repo-detail"> | |
<h1>Repository: {this.state.repo.name}</h1> | |
</div> | |
) | |
} | |
} | |
export default RepoDetail; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment