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

TypeError: Cannot read property 'some' of undefined #414

Closed
AnnaCate opened this issue Nov 10, 2020 · 4 comments · Fixed by #415
Closed

TypeError: Cannot read property 'some' of undefined #414

AnnaCate opened this issue Nov 10, 2020 · 4 comments · Fixed by #415
Labels

Comments

@AnnaCate
Copy link

I'm seeing a TypeError: Cannot read property 'some' of undefined for users on Chrome 86 and Samsung Internet 5.2, so far only for users on a SM-J727T device.

The error seems to be originating from:

const inView =
entry.isIntersecting &&
observer.thresholds.some(
(threshold) => entry.intersectionRatio >= threshold,
);

I'm already employing the 'intersection-observer' polyfill.

A similar issue was raised in #192 and resolved in #194, but it seems that the code has since changed.

@thebuilder
Copy link
Owner

Hey @AnnaCate, that sounds weird - Can you share the options you pass when creating the observer? The observer instance should have the thresholds array according to the spec.

I'm not seeing in myself running Chrome 86 in a Codesandbox: https://codesandbox.io/s/useinview-ud2vo?fontsize=14&hidenavigation=1&theme=dark

It might make sense to just add the fix implemented in #194 - just to be sure threshold is defined.

thebuilder added a commit that referenced this issue Nov 11, 2020
Sometimes the thresholds value on the IntersectionObserver instance could be undefined. Add a fallback to a default value in the cases where the browser doesn't set it.

This fixes #414
@thebuilder
Copy link
Owner

🎉 This issue has been resolved in version 8.30.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@AnnaCate
Copy link
Author

@thebuilder thank you for the quick resolution. FWIW this these are the options being passed:

  const { ref, inView } = useInView({
    threshold: 0.9,
    triggerOnce: true,
  })

@thebuilder
Copy link
Owner

That's really weird. The solution I made assumes it's defined, and reverts to 0 threshold otherwise.

If you are seeing this with an actual threshold, it wouldn't work as expected. Might look into taking the value you supplied in the options.

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 a pull request may close this issue.

2 participants