Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/reactjs/reactjs.org into …
Browse files Browse the repository at this point in the history
…sync-ad6687e2
  • Loading branch information
reactjs-translation-bot committed May 6, 2019
2 parents 354c275 + ad6687e commit a7bcf93
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions content/docs/hooks-faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -809,13 +809,10 @@ function Image(props) {

// ✅ IntersectionObserver is created lazily once
function getObserver() {
let observer = ref.current;
if (observer !== null) {
return observer;
if (ref.current === null) {
ref.current = new IntersectionObserver(onIntersect);
}
let newObserver = new IntersectionObserver(onIntersect);
ref.current = newObserver;
return newObserver;
return ref.current;
}

// When you need it, call getObserver()
Expand Down

0 comments on commit a7bcf93

Please sign in to comment.