Skip to content

Instantly share code, notes, and snippets.

@icarus-sullivan
Created July 4, 2019 18:37
Show Gist options
  • Save icarus-sullivan/f53801b87c364c5f6bd3ff3df981bbf8 to your computer and use it in GitHub Desktop.
Save icarus-sullivan/f53801b87c364c5f6bd3ff3df981bbf8 to your computer and use it in GitHub Desktop.
Illustrates how to call useAsync
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