1import React from 'react';
2
3import axios from 'axios';
4
5export default class PersonList extends React.Component {
6 state = {
7 persons: []
8 }
9
10 componentDidMount() {
11 axios.get(`https://jsonplaceholder.typicode.com/users`)
12 .then(res => {
13 const persons = res.data;
14 this.setState({ persons });
15 })
16 }
17
18 render() {
19 return (
20 <ul>
21 { this.state.persons.map(person => <li>{person.name}</li>)}
22 </ul>
23 )
24 }
25}
26