Skip to content

Instantly share code, notes, and snippets.

@moonformeli
Created May 18, 2017 05:31
Show Gist options
  • Save moonformeli/310de3aaf8568cd3bbe2103238520786 to your computer and use it in GitHub Desktop.
Save moonformeli/310de3aaf8568cd3bbe2103238520786 to your computer and use it in GitHub Desktop.
quiz_item_empty.js
class Quiz extends React.Component {
constructor(props) {
super(props);
// Initialized, but not enough
this.state = {};
}
componentWillMount() {
// Get the data "soon"
axios.get('/thedata').then(res => {
this.setState({items: res.data});
});
}
render() {
return (
<ItemList items={this.state.items}/>
);
}
}
function ItemList({ items }) {
return (
<ul>
{items.map(item =>
<li key={item.id}>{item.name}</li>
)}
</ul>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment