Skip to content

Instantly share code, notes, and snippets.

@vnglst
Last active February 6, 2017 09:06
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 vnglst/7d39576662c336e85d75475f8edd09f9 to your computer and use it in GitHub Desktop.
Save vnglst/7d39576662c336e85d75475f8edd09f9 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react'
import './App.css'
import { getUser } from './api/github'
const renderLine = (user, key) => <li key={key}><b>{key}</b>: {user[key]}</li>
class App extends Component {
constructor (props) {
super(props)
this.state = { user: {} }
}
componentDidMount () {
getUser('vnglst').then(data => {
this.setState({ user: data.entity })
})
}
render () {
const { user } = this.state
return (
<div className='App'>
<ul style={{ listStyle: 'none' }}>
{
// Loop over the object keys and render each key
Object.keys(user).map(key => renderLine(user, key))
}
</ul>
</div>
)
}
}
export default App
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment