Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: skip creating the observer if nothing changed #360

Closed
wants to merge 1 commit into from

Conversation

thebuilder
Copy link
Owner

Fix for #359 - Ensure that we don't recreate the InteresectionObserver if the node and options are are the same.

This happens when wrapping the ref without using useCallback.

@vercel
Copy link

vercel bot commented Aug 10, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/the-builder/react-intersection-observer/bex10d3by
✅ Preview: https://react-intersection-observer-git-fix-infinite-ref-rerender.the-builder.vercel.app

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 9abc46a:

Sandbox Source
react-intersection-observer Configuration

@thebuilder
Copy link
Owner Author

Seems like this doesn't actually work. 😔

React makes a call with null as the node before it switches to the new (same) node, so it still enters the same infinite loop.

@thebuilder thebuilder closed this Aug 21, 2020
@thebuilder thebuilder deleted the fix/infinite-ref-rerender branch August 21, 2020 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant