(id, timeout)
| 8 | const cachePool: any[] = []; |
| 9 | |
| 10 | function 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 | |
| 20 | export function Cpn({ id, timeout }) { |
| 21 | const [num, updateNum] = useState(0); |