v8.33.0
8.33.0 (2021-12-09)
Features
This is solution for #495 that adds support for a fallbackInView
value.
You can set the fallback globally:
import { defaultFallbackInView } from 'react-intersection-observer';
defaultFallbackInView(true); // or 'false'
You can also define the fallback locally on useInView
or <InView>
as an
option. This will override the global fallback value.
import React from 'react';
import { useInView } from 'react-intersection-observer';
const Component = () => {
const { ref, inView, entry } = useInView({
fallbackInView: true,
});
return (
<div ref={ref}>
<h2>{`Header inside viewport ${inView}.`}</h2>
</div>
);
};