fix: return the revalidator in useLiveData
This commit is contained in:
parent
e6eba645c4
commit
18999357a8
@ -2,11 +2,11 @@ import { useRevalidator } from '@remix-run/react'
|
|||||||
import { useEffect } from 'react'
|
import { useEffect } from 'react'
|
||||||
import { useInterval } from 'usehooks-ts'
|
import { useInterval } from 'usehooks-ts'
|
||||||
|
|
||||||
type Properties = {
|
interface Props {
|
||||||
interval: number;
|
interval: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useLiveData({ interval }: Properties) {
|
export function useLiveData({ interval }: Props) {
|
||||||
const revalidator = useRevalidator()
|
const revalidator = useRevalidator()
|
||||||
|
|
||||||
// Handle normal stale-while-revalidate behavior
|
// Handle normal stale-while-revalidate behavior
|
||||||
@ -31,4 +31,5 @@ export function useLiveData({ interval }: Properties) {
|
|||||||
document.removeEventListener('focus', handler)
|
document.removeEventListener('focus', handler)
|
||||||
}
|
}
|
||||||
}, [revalidator])
|
}, [revalidator])
|
||||||
|
return revalidator
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user