UNPKG

sanity

Version:

Sanity is a real-time content infrastructure with a scalable, hosted backend featuring a Graph Oriented Query Language (GROQ), asset pipelines and fast edge caches

13 lines (10 loc) 362 B
import {type Subscriber} from 'nano-pubsub' import {useContext, useEffect} from 'react' import {ScrollContext} from './scrollContext' /** @internal */ export function useOnScroll(callback: Subscriber<Event>) { const parentContext = useContext(ScrollContext) useEffect(() => { return parentContext?.subscribe(callback) }, [callback, parentContext]) }