Add the ability to configure that once inView is true, to keep it true
christiaanwesterbeek opened this issue · 2 comments
christiaanwesterbeek commented
We would like to not destroy a component that has been rendered because it came into view. I'm going to implement something to make it happen. But it would be nice if I'm able to configure that. It's, for example the way that https://github.com/elinadenfina/useinview is working. Once that inView
is true
it doesn't become false
again.
christiaanwesterbeek commented
Forget that I requested it. It's too simple to implement
const [ref, inView] = useInView();
const [wasOnceVisible, setWasOnceVisible] = useState(inView);
useEffect(() => {
if (inView) {
setWasOnceVisible(true);
}
}, [inView]);
Then use wasOnceVisible
instead of inView
from here.
bitmap commented
You can pass the unobserveOnEnter
option which will detach the intersection observer so inView
remains true
.
const [ref, inView] = useInView({
unobserveOnEnter: true
});