Skip to content

Instantly share code, notes, and snippets.

@dceddia
Created October 10, 2017 23:11
Show Gist options
  • Save dceddia/29eec311985239832b598cf7c927ce1f to your computer and use it in GitHub Desktop.
Save dceddia/29eec311985239832b598cf7c927ce1f to your computer and use it in GitHub Desktop.
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