Intersection Observer Hooks
Table of Contents
useInView
useInViewUsage
import useInView from "@frontity/hooks/use-in-view";
const MyLazyElement = ({ children }) => {
// Get the reference and the visibility status.
const { ref, inView } = useInView({ triggerOnce: true });
// Pass the reference to the container and render `children` if
// the container is visible, or a placeholder otherwise.
return <div ref={ref}>{inView ? children : <MyPlaceholder />}</div>;
};Parameters
Return value
Demo
Last updated