Created
January 7, 2022 16:59
-
-
Save pkellner/5d809ca32f6ea9990aed303d61866f2a to your computer and use it in GitHub Desktop.
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
function Demo() { | |
const fetcher = (url) => fetch(url).then((r) => r.json()); | |
const { data } = useSwr( | |
`https://jsonplaceholder.typicode.com/todos`, | |
fetcher, | |
{ suspense: false } | |
); | |
if (!data) return <div>Loading... (pre-Suspense)</div>; | |
return ( | |
<div className="container grid"> | |
{data.map((rec) => { | |
return ( | |
<div className="row" key={rec.id}> | |
<div className="col-2">{rec.userId}</div> | |
<div className="col-8">{rec.title}</div> | |
<div className="col-2">{rec.completed === true ? "yes" : "no"}</div> | |
</div> | |
); | |
})} | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment