Created
October 13, 2021 04:42
-
-
Save devmnj/c6a1058a0a22881b2f617c58ab2a8724 to your computer and use it in GitHub Desktop.
Vercer useSWR example
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 Profile () { | |
const { data, error } = useSWR('/api/user/123', fetcher) | |
if (error) return <div>failed to load</div> | |
if (!data) return <div>loading...</div> | |
// render data | |
return <div>hello {data.name}!</div> | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment