npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-section

v1.1.11

Published

Marking dom element

Readme

react-section

npm -i react-section

Live_Demo

Live-Demo-Code

Marking dom element mostly use for getting element position and offsets, scroll to element or implement lazy loading


All functions and props

 componentDidMount() {
    console.log(this.section);
    this.section.getFlagsOffSet()
    this.section.getFlagsPosition()
    this.section.flagsNode
    this.section.flagsRef
    this.section.inViewFlag
    this.section.scrollToFlag()
}

Scroll to section

class App extends Component {
  constructor(props) {
    super(props);
    this.section = React.createRef();
  }

  onClick = flag => {
    this.section.scrollToFlag(flag);
  };
  render() {
    return (
      <Section onRef={ref => (this.section = ref)}>
        <button onClick={() => this.onClick("header")}>Go to header</button>
        <button onClick={() => this.onClick("body")}>Go to body</button>
        <Section.Flag
          style={{ height: "30vh", marginTop: "60px" }}
          flagName="header"
        >
          <h1>Header</h1>
        </Section.Flag>
        <Section.Flag className="body" flagName="body">
          <h1>Body</h1>
        </Section.Flag>
      </Section>
    );
  }
}

scrollToFlag = (flagName, top = 0, duration = 500) => {..}

flagName: Name of marking flag is required
top: Offset from top default is 0
duration: Duration default is 500


Lazyload

<Section onRef={ref => (this.section = ref)}>
  <!-- Flag will not accept children is lazyLoad props is provided -->
  <Section.Flag
    lazyLoad={{
      // Loaded delay time
      delay: 2000,
      // initProps apply to Flag not the loading component
      initProps: {
        className: "beforeload",
        style: {
          backgroundColor: "green"
        }
      },
      // Props component will receivie after it is loaded
      loadedProps: { onClick: () => alert("Hi i'm lazy 1") }
      loading: () => <h1>I will load after 2s</h1>,
      loaded: () => import("./component/Loaded"),
  }}
    flagName="lazyheader"
    className="component__lazy"
  />
  <Section.Flag
    lazyLoad={{
      // Again these props apply to the Flag not the component
      // and will be remove after component is loaded
      initProps: {
        className: "beforeload",
        style: {
          backgroundColor: "green"
        }
      },
      // Component will be loaded when appear in to viewport
      loadOnView: true,
      // Component will be loaded when scroll down 200px from it
      fromBottom: 200,
      loadedProps: {
          onClick: () => alert("Hi i'm lazy 2")
      }
      loading: () => <h1>Scroll down 200px from me to load</h1>,
      loaded: () => import("./component/Loaded2"),
    }}
    flagName="lazyheader2"
    className="component__lazy"
  />
</Section>

Peer dependencies: "react-scroll": "^1.7.10"