Created
July 4, 2019 18:37
-
-
Save icarus-sullivan/f53801b87c364c5f6bd3ff3df981bbf8 to your computer and use it in GitHub Desktop.
Illustrates how to call useAsync
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 { useAsync } from '@sullivan/use-async'; | |
const Example = (props) => { | |
const { loading, data, error, dispatch } = useAsync(fetch, 'https://www.npmjs.com/package/@sullivan/use-async'); | |
return ( | |
<button onClick={dispatch}>Request Page</button> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment