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: add componentDidMount to InView #650

Merged
merged 1 commit into from
Nov 9, 2023
Merged

Conversation

thebuilder
Copy link
Owner

Next.js has updated or changed React, causing it to call componentWillUnmount, followed by componentDidMount. The componentDidMount was not included in the <InView> component, causing it to just unmount itself.

This is most likely caused by StrictMode, similar to how it tests useEffect.
https://react.dev/reference/react/Component#componentdidmount

Why it hasn't been a problem before, and only affects the Next.js app router is a great question.

Fixes #649

Copy link

vercel bot commented Nov 9, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
react-intersection-observer ✅ Ready (Inspect) Visit Preview Nov 9, 2023 6:58pm

Copy link

codesandbox-ci bot commented Nov 9, 2023

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 5da81d2:

Sandbox Source
useInView Configuration
InView render props Configuration
InView plain children Configuration

@thebuilder thebuilder merged commit 9699c31 into main Nov 9, 2023
7 checks passed
@thebuilder thebuilder deleted the fix/649-next-js-inview branch November 9, 2023 19:00
@thebuilder
Copy link
Owner Author

🎉 This PR is included in version 9.5.3 🎉

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.

InView Component Doesn't Trigger onChange After Updating to Latest NextJS Version
1 participant