UNPKG

react-hooks-global-scrollspy

Version:
12 lines (11 loc) 546 B
import { useContext } from "react"; import { GlobalScrollSpyContext } from "./GlobalScrollSpyContext"; /** * @returns [ activeElement, actions ] - Two return values are returned as an array * @returns activeElement - DOM element activated based on scroll position (only one) * @returns actions - Actions are used to control registered DOM elements */ export var useGlobalScrollSpy = function () { var _a = useContext(GlobalScrollSpyContext), activeElement = _a.activeElement, actions = _a.actions; return [activeElement, actions]; };