Last active
July 4, 2019 19:13
-
-
Save icarus-sullivan/b09e95041bf0f10916dd49e46fb86634 to your computer and use it in GitHub Desktop.
Tie page fetch directly to 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, { 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