0.1.5 • Published 4 years ago

@nicolastoulemont/use-fetch v0.1.5

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

Use-form

This use-fetch utility hook implement state-while-revalidate data-fetching with a cache using sha-256 hashs of the request url and params as keys.

Disclaimer

This is a work in progress tool and mainly aimed at my personal use accross my projects.

Installation

npm install @nicolastoulemont/use-fetch
or
yarn add @nicolastoulemont/use-fetch

Usage

  • Basic usage
import { useFetch } from '@nicolastoulemont/use-fetch';

export function BasicComponent() {
  const { response, loading, error, fetchy } = useFetch(
    '[DATA_SOURCE_URL]',
    fetchOptions
  );

  return (
    <div>
      <button onClick={fetchy}></button>
      {loading && <div>Loading...</div>}
      {response && <div>{JSON.stringify(response, null, 2)}</div>}
    </div>
  );
}

Built with

Versionning

This tool use SemVer for versioning.

Licence

MIT

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago