2.0.1 • Published 3 years ago

use-active-heading v2.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

use-active-heading

Determine which section a user is reading with IntersectionObservers

NPM JavaScript Style Guide

Install

npm install --save use-active-heading

Usage

import * as React from "react";

import { useActiveHeading } from "use-active-heading";

const Example = () => {
  const activeId = useActiveHeading(["#a", "#b"], {});
  return (
    <>
      <p>ActiveId:{activeId}</p>
      <h1 id="a">A</h1>
      <h2 id="b" style={{ marginTop: "100vh" }}>
        B
      </h2>
    </>
  );
};

License

MIT © sallto


Thanks to create-react-hook for making the npm process understandable.