Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@rayashi
Created May 10, 2020 23:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rayashi/0a50f2a91493298509c92559c7ca967c to your computer and use it in GitHub Desktop.
Save rayashi/0a50f2a91493298509c92559c7ca967c to your computer and use it in GitHub Desktop.
import React from "react";
import ContentLoader from "./ContentLoader";
import { useParams } from "react-router-dom";
export default ({ userId }) => {
let { id } = useParams();
const getUserDetail = async () => {
return await (
await fetch(`https://reqres.in/api/users/${id}?delay=1`)
).json();
};
return (
<ContentLoader
getContent={getUserDetail}
render={(user) => (
<div>
<p>{user?.data?.first_name}</p>
<p>{user?.data?.email}</p>
</div>
)}
/>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment