react-fetch-hook
Advanced tools
Comparing version 1.1.0 to 1.2.0
{ | ||
"name": "react-fetch-hook", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "React fetch hook", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
# react-fetch-hook | ||
[![Build Status](https://travis-ci.org/ilyalesik/react-fetch-hook.svg?branch=master)](https://travis-ci.org/ilyalesik/react-fetch-hook) | ||
[![npm version](https://img.shields.io/npm/v/react-fetch-hook.svg)](https://www.npmjs.com/package/react-fetch-hook) | ||
[![npm downloads](https://img.shields.io/npm/dt/react-fetch-hook.svg)](https://www.npmjs.com/package/react-fetch-hook) | ||
React hook, which allows you to conveniently work with *fetch*. Good Flow support. | ||
@@ -4,0 +8,0 @@ |
// @flow | ||
import { usePromise } from "./usePromise"; | ||
type TUseFetchResult = { | ||
data: ?mixed, | ||
type TUseFetchResult<T> = { | ||
data: ?T, | ||
isLoading: boolean, | ||
@@ -10,6 +10,6 @@ error: mixed | ||
export function useFetch( | ||
export function useFetch<T>( | ||
path: RequestInfo, | ||
options?: { ...RequestOptions, formatter?: Response => Promise<mixed> } | ||
): TUseFetchResult { | ||
options?: { ...RequestOptions, formatter?: Response => Promise<T> } | ||
): TUseFetchResult<T> { | ||
const defaultFormatter = response => response.json(); | ||
@@ -22,6 +22,6 @@ const fetchInstance = formatter => (path, options) => { | ||
return usePromise(fetchInstance(formatter), path, fetchOptions); | ||
return usePromise((fetchInstance(formatter): any), path, fetchOptions); | ||
} else { | ||
return usePromise(fetchInstance(), path); | ||
return usePromise((fetchInstance(): any), path); | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18039
16
290
62