Created
May 25, 2021 23:12
-
-
Save raflyfahrezi/5e249784fff776c6a39237ba1c90f622 to your computer and use it in GitHub Desktop.
fetcing data using swr
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 useSWR from 'swr' | |
import { fetcher } from '../utils' | |
const index = () => { | |
const { data } = useSWR('... some API Fetch ...', fetcher) | |
return ( | |
<div> | |
{data ? ( | |
<div> | |
{data.map((item, index) => { | |
return ( | |
<div>...</div> | |
) | |
})} | |
</div> | |
) : ( | |
<div> | |
<p>Loading</p> | |
</div> | |
)} | |
</div> | |
) | |
} | |
export default index |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment