Skip to content

Conversation

@thebuilder
Copy link
Owner

This changes the rendering flow in the <InView> component, optimizing it for the children.

Previously it had a an internal state used to store the current inView and entry values. But it was only really used by the component when using the render props pattern. This lead to unnecessary renders for the plain component.

Another optimization tried to limit the state updates, so it would only occur if inView changed. This however meant you wouldn't get the correct entry value in the render prop, since it would only update when inView changes. This would prevent you from getting the latest threshold or isVisible values.

@vercel
Copy link

vercel bot commented Sep 23, 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/rff0h9dc9
✅ Preview: https://react-intersection-observer-git-fix-optimize-inview.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 e0c360d:

Sandbox Source
react-intersection-observer Configuration

@thebuilder thebuilder merged commit b3e2959 into master Sep 24, 2020
@thebuilder thebuilder deleted the fix/optimize-inView branch September 24, 2020 08:02
@thebuilder
Copy link
Owner Author

🎉 This PR is included in version 8.28.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants