github thebuilder/react-intersection-observer v6.0.0
Simpler times

latest releases: v10.0.0, v9.16.0, v9.15.1...
7 years ago

Looking at how i'm currently using react-intersection-observer, and how render props have been adapted by React, this release moves all rendering to to the children prop.

The way to use the component is to forward the ref to your outer element, giving you full control over the DOM.

import Observer from 'react-intersection-observer'

const Component = () => (
  <Observer>
    {({ inView, ref }) => (
      <div ref={ref}>
        <h2>{`Header inside viewport ${inView}.`}</h2>
      </div>
    )}
  </Observer>
)

export default Component

⚠️ Breaking changes

  • Deprecated renderprop
  • Deprecated tag prop
  • Deprecated child as React.Node

They will still work for now, but you'll get a deprecation warning unless NODE_ENV is production.

If you are currently using render, you can move the method directly to children.

Don't miss a new react-intersection-observer release

NewReleases is sending notifications on new releases.