Skip to content

Releases: onderonur/react-intersection-observer-hook

v3.0.1

17 Aug 23:46
Compare
Choose a tag to compare

Fixed peerDependencies by adding react-dom.

v3.0.0

11 Aug 12:44
Compare
Choose a tag to compare

v2.1.1

28 Feb 19:16
Compare
Choose a tag to compare

Observer cache improvement for using different observers on the same element

v2.1.0

26 Feb 17:15
Compare
Choose a tag to compare

Observer cache & removed unnecessary useEffect

v2.0.6

16 Oct 18:56
Compare
Choose a tag to compare

Minor refactor for useTrackVisibility.

v2.0.5

15 Oct 16:11
Compare
Choose a tag to compare

IntersectionObserverHookArgs type is fixed by omitting root from IntersectionObserverInit.

v2.0.4

02 Apr 21:47
Compare
Choose a tag to compare

React 18 issue for unmount-remount in StrictMode is fixed

v2.0.3

04 Apr 19:59
Compare
Choose a tag to compare

Fix for typings of hook results.

v2.0.2

04 Apr 03:10
Compare
Choose a tag to compare

Minor changes for README.md.
Just published this to update it on npm.

v2.0.1

03 Apr 23:38
Compare
Choose a tag to compare

This is a major version bump.
It includes some fix for dynamically changing config object. When the given config changes, the hook wasn't re-render like it should. It would use the initially created IntersectionObserver instance. Now, we have this fixed.

Setting the Root Node

Also, we have a better API to set root node now.
Note: Both, useIntersectionObserver and useTrackVisibility has the same API. They just return different results.

Before v2

const getRoot = () => document.getElementById("rootNode")

function SomeComponent() {
     const [ref, { entry }] = useIntersectionObserver({ root: getRoot });

     // ...

     return (
          <div id="rootNode">
              <div ref={ref}>
                    Some content
              </div>
          </div>
     )
}

After v2

function SomeComponent() {
     const [ref, { entry, rootRef }] = useIntersectionObserver();

     // ...

     return (
          <div ref={rootRef } >
              <div ref={ref}>
                   Some content
              </div>
          </div>
     )
}

New wasEverVisible Field by useTrackVisibility

useTrackVisibility hook now returns a field (wasEverVisible) that flips to true when the observed node becomes visible once.

function SomeComponent() {
     const [ref, { isVisible, wasEverVisible }] = useTrackVisibility();

     // ...

     return (
          <div>
              <div ref={ref}>
                   Some content
              </div>
          </div>
     )
}