Last active
June 1, 2019 07:48
-
-
Save ivan-ha/83d4e65fa201a2e46d28473856c47a1c to your computer and use it in GitHub Desktop.
react-hooks-test-traditional-way
This file contains hidden or 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 App extends React.Component { | |
| state = { users: [] }; | |
| componentDidMount() { | |
| axios("https://randomuser.me/api/?results=10&inc=name,login&nat=us").then( | |
| response => { | |
| this.setState({ | |
| users: response.data.results | |
| }); | |
| } | |
| ); | |
| } | |
| render() { | |
| const { users } = this.state; | |
| return ( | |
| <ol> | |
| {users && | |
| users.map(({ name, login }) => ( | |
| <li key={login.uuid}> | |
| {`${name.title} ${name.first} ${name.last}`} | |
| </li> | |
| ))} | |
| </ol> | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment