This file contains 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 from 'react' | |
/** | |
* @typedef {object} State The state of asynchronous hooks. | |
* @property {object | null} error The error. | |
* @property {boolean} pending Whether the call is pending. | |
* @property {any | null} result The result of the asynchronous call. | |
*/ | |
/** @type {State} */ |
This file contains 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 { fetchDedupe, getRequestKey, isRequestInFlight } from 'fetch-dedupe' | |
import { useEffect, useRef, useState } from 'react' | |
// This in the Fetch component transposed in hooks. | |
// https://github.com/jamesplease/react-request/issues/199 | |
// https://github.com/jamesplease/react-request/blob/master/src/fetch.js | |
// This object is our cache. | |
// The keys of the object are requestKeys. | |
// The value of each key is a Response instance. |
NewerOlder