Created
October 10, 2017 23:11
-
-
Save dceddia/29eec311985239832b598cf7c927ce1f 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, { Component } from 'react'; | |
import './App.css'; | |
class App extends Component { | |
state = {users: []} | |
componentDidMount() { | |
fetch('/users') | |
.then(res => res.json()) | |
.then(users => this.setState({ users })); | |
} | |
render() { | |
return ( | |
<div className="App"> | |
<h1>Users</h1> | |
{this.state.users.map(user => | |
<div key={user.id}>{user.username}</div> | |
)} | |
</div> | |
); | |
} | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment