Skip to content

tscharke/useIntersection

 
 

Repository files navigation

Create Release Workflow Release

useIntersection hook

This project is a custom hook for React that uses the IntersectionObserver API to observe a DOM element.

When to use useIntersection and useIntersectionRef?

useIntersection

classical useIntersection hook with useEffect and useRef

useIntersectingRef

same as useIntersection but with avoiding the need to use useEffect and useRef, allows intersection on optional or delayed elements

Getting Started

Prerequisites

  • Node.js
  • pnpm

Installing

pnpm i

Running the tests

pnpm test

Building

pnpm build

Create a new release

To create a new release, it is necessary to set and push a (Git)Tag like:

git tag v1.2.3 && git push origin tag v1.2.3

What is crucial here is that the tag begins with a lowercase v followed by a Semantic Versioning - a tag will then look like this: v1.2.3.

From this, a GitHub Action then creates a tar file with the name by this pattern:

${NAME_OF_THIS_PROJECT}-${SEMANTIC_VERSIONING_OF_TAG}.tar.gz

// Output: useintersection-1.2.3.tar.gz

Which tar file can be used as a dependency in other projects. To do this, this tar file must be downloaded and can then be used installed in another project like this:

pnpm install ../../my-location/useintersection-1.2.3.tar.gz

Built With

About

react hook using intersection observer

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • TypeScript 97.4%
  • JavaScript 2.6%