1.0.37 - The time update
BREAKING CHANGES
- Changed
useSingle()
anduseScroll()
to use new time parameters
useSingle(key, fetcher, { cooldown, timeout, expiration })
useScroll(scroller, fetcher, { cooldown, timeout, expiration })
CHANGES
- You can now use an expiration delay in your handles
useSingle(key, fetcher, { expiration: 60 * 1000 })
useScroll(scroller, fetcher, { expiration: 60 * 1000 })
- You can now return a cooldown time in your fetcher
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 }
}
- You can now use time parameters in CoreProvider
function MyWrapper() {
return <XSWR.CoreProvider
cooldown={1000}
timeout={5000}
expiration={60 * 1000}>
<MyAwesomeApp />
</XSWR.CoreProvider>
}