Last active
May 10, 2020 23:38
-
-
Save rayashi/28e12f9c7b169b0fd84c14df5b7e6504 to your computer and use it in GitHub Desktop.
UserList
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
import React from "react"; | |
import ContentLoader from "./ContentLoader"; | |
import { Link } from "react-router-dom"; | |
export default () => { | |
const getUsers = async () => { | |
return await (await fetch("https://reqres.in/api/users?delay=1")).json(); | |
}; | |
return ( | |
<ContentLoader | |
getContent={getUsers} | |
render={(users) => ( | |
<div className="user-list"> | |
{users?.data?.map((user) => ( | |
<Link to={`/users/${user.id}`}> | |
<img className="avatar" alt={user.id} src={user.avatar} /> | |
</Link> | |
))} | |
</div> | |
)} | |
/> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment