Skip to content

Instantly share code, notes, and snippets.

@icarus-sullivan
Last active July 4, 2019 19:13
Show Gist options
  • Save icarus-sullivan/b09e95041bf0f10916dd49e46fb86634 to your computer and use it in GitHub Desktop.
Save icarus-sullivan/b09e95041bf0f10916dd49e46fb86634 to your computer and use it in GitHub Desktop.
Tie page fetch directly to useAsync
import React, { useState } from 'react';
import { withAsync } from '@sullivan/use-async';
const PageFetch = ({ loading, data, error, dispatch }) => (
<div>
<button enabled={!loading} onClick={dispatch}>Request Page</button>
<pre>{JSON.stringify({ loading, data, error })}</pre>
</div>
);
export default withAsync(fetch, '')(PageFetch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment