We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents b215f99 + ad6687e commit b941619Copy full SHA for b941619
content/docs/hooks-faq.md
@@ -809,13 +809,10 @@ function Image(props) {
809
810
// ✅ IntersectionObserver is created lazily once
811
function getObserver() {
812
- let observer = ref.current;
813
- if (observer !== null) {
814
- return observer;
+ if (ref.current === null) {
+ ref.current = new IntersectionObserver(onIntersect);
815
}
816
- let newObserver = new IntersectionObserver(onIntersect);
817
- ref.current = newObserver;
818
- return newObserver;
+ return ref.current;
819
820
821
// When you need it, call getObserver()
0 commit comments