Skip to content

Releases: ilyalesik/react-fetch-hook

Improving useFetch error

12 Feb 09:32
Compare
Choose a tag to compare

Has implemented the ability to get error status code:

...

const Component = () => {
  const { isLoading, data, error } = useFetch("https://swapi.co/api/people/1");

  if (error) {
    return <div>
      <p>Code: ${error.status}</p>
      <p>Message: ${error.statusText}</p>
    </div>
  }
 
  ...
};

isLoading=true by default

01 Oct 20:54
Compare
Choose a tag to compare
v1.7.0

Make isLoading true by default #13

v1.6.4

10 Jul 19:42
Compare
Choose a tag to compare

Improve usePaginatedRequest

Add TypeScript typings

08 May 10:38
Compare
Choose a tag to compare

TypeScript typings is now included to package.

Add `usePaginatedRequest`

27 Apr 05:53
Compare
Choose a tag to compare

usePaginatedRequest

Create a paginated request.

usePaginatedRequest = <T>(
    request: (params: { limit: number, offset: number }) => Promise<Array<T>>,
    limit: number
): {
    data: Array<T>,
    loadMore?: () => mixed,
    hasMore: boolean
};

Implement prevent call fetch

14 Mar 15:52
Compare
Choose a tag to compare

Implement prevent call fetch

For prevent call fetch you can pass preventCallFetch prop:

const {authToken} = useContext(authTokenContext);
const { isLoading, data } = useFetch("https://swapi.co/api/people/1", {
    preventCallFetch: !authToken //don't call request, if haven't authToken
});