Bot releases are visible (Hide)
Published by hazae41 about 2 years ago
BREAKING CHANGES
useSingle()
and useScroll()
to use new time parametersuseSingle(key, fetcher, { cooldown, timeout, expiration })
useScroll(scroller, fetcher, { cooldown, timeout, expiration })
CHANGES
useSingle(key, fetcher, { expiration: 60 * 1000 })
useScroll(scroller, fetcher, { expiration: 60 * 1000 })
async function fetchAsJson<T>(url: string) {
const res = await fetch(url)
if (!res.ok) throw new Error(await res.text())
const data = await res.json() as T
const cooldown = Date.now() + 5000
const expiration = Date.now() + (60 * 1000)
return { data, cooldown, expiration }
}
function MyWrapper() {
return <XSWR.CoreProvider
cooldown={1000}
timeout={5000}
expiration={60 * 1000}>
<MyAwesomeApp />
</XSWR.CoreProvider>
}
Published by hazae41 about 2 years ago
Now ES6 compatible, tree-shakeable and side-effects free!