Skip to content

Instantly share code, notes, and snippets.

@ivan-ha
Last active June 1, 2019 07:48
Show Gist options
  • Select an option

  • Save ivan-ha/83d4e65fa201a2e46d28473856c47a1c to your computer and use it in GitHub Desktop.

Select an option

Save ivan-ha/83d4e65fa201a2e46d28473856c47a1c to your computer and use it in GitHub Desktop.
react-hooks-test-traditional-way
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