
Description
react-on-screen is a small React wrapper component that reports whether its children are visible on the screen. It watches the viewport and sets a flag when the wrapped component scrolls into view, which makes it useful for lazy loading images, starting animations or tracking which content a visitor has seen. You can use it in a simple form, or with a render prop that receives the visibility state. Options let you track visibility only once, which removes the event listeners after the first time the element appears, and set an offset that changes how far outside the viewport still counts as visible. The partialVisibility option treats the element as visible as soon as any part of it is on screen. A tag prop sets which HTML element wraps the children, and a throttleInterval setting controls how often the scroll and resize listeners run. The README includes a demo and a full API table. It is aimed at React developers who need viewport detection, and it is installed from npm, with a UMD build also available for pages that do not use a bundler.…
Highlights
- Detects when a React component is in view
- Simple wrapper or render prop usage
- Track visibility once, then stop listening
- Offset and partial visibility options
- Installed from npm, UMD build available
Ratings & Reviews
No ratings yet
Be the first to rate react-on-screen.
People also visit

react-waypoint
A React component to execute a function whenever you scroll to an element

react-lazy-load-image-component
React Component to lazy load images using a HOC to track window scroll position

react-lazyload
Lazyload your Component, Image or anything else where the performance matters
react-on-screen FAQ
What does react-on-screen do?
It is a React wrapper that tells you whether the component inside it is visible in the viewport.
How do I install it?
Install it from npm. The README also lists a UMD build for use without a bundler.
Can it help lazy load images?
Yes. The README suggests using the offset option to start loading an image shortly before it scrolls into view.
Can a component count as visible when only part of it shows?
Yes. Set the partialVisibility prop to count the component as visible as soon as any part of it is on screen.
Can I use a different HTML element as the wrapper?
Yes. The tag prop sets the element used as the wrapper, and it defaults to a div.
What are the best react-on-screen alternatives?
Popular alternatives to react-on-screen include react-visibility-sensor, react-lazy-load and react-waypoint. See all react-on-screen alternatives
















