Created
May 18, 2017 05:31
-
-
Save moonformeli/310de3aaf8568cd3bbe2103238520786 to your computer and use it in GitHub Desktop.
quiz_item_empty.js
This file contains 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
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