MCPcopy
hub / github.com/BetaSu/big-react / fetchData

Function fetchData

demos/suspense-use/Cpn.tsx:10–18  ·  view source on GitHub ↗
(id, timeout)

Source from the content-addressed store, hash-verified

8const cachePool: any[] = [];
9
10function fetchData(id, timeout) {
11 const cache = cachePool[id];
12 if (cache) {
13 return cache;
14 }
15 return (cachePool[id] = delay(timeout).then(() => {
16 return { data: Math.random().toFixed(2) * 100 };
17 }));
18}
19
20export function Cpn({ id, timeout }) {
21 const [num, updateNum] = useState(0);

Callers 1

CpnFunction · 0.85

Calls 2

delayFunction · 0.70
thenMethod · 0.65

Tested by

no test coverage detected