Created
May 18, 2017 03:44
-
-
Save moonformeli/d6571b8ca702bc34c89e4c27c8bdc9a4 to your computer and use it in GitHub Desktop.
componentWillMount example
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 Component { | |
componentWillMount() { | |
axios.get('/thedata').then(res => { | |
this.setState({items: res.data}); | |
}); | |
} | |
render() { | |
return ( | |
<ul> | |
{this.state.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