question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HOC doesn't track scroll position - `scrollPosition` is always `null`

See original GitHub issue

Bug description I’m wrapping a component in trackScrollPosition, and it’s adding scrollPosition to the component props, but it’s always null.

To Reproduce See it here: https://stackblitz.com/edit/react-x6zjfs

Expected behavior I’d expect scrollPosition to update whenever the window scrolls.

Screenshots N/A

Technical details:

  • Package version: 1.3.2
  • Server Side Rendering? No
  • Device: Desktop
  • Operating System: Mac OS
  • Browser: Chrome

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Aljullucommented, Jul 27, 2019

Right, as @FacundoMainere said if your browser supports IntersectionObserver, the HOC doesn’t pass trackScrollPosition down.

Would a useIntersectionObserver prop which allows disabling the IntersectionObserver be useful? I created a WIP PR here: #45, feel free to take a look.

0reactions
Aljullucommented, Oct 5, 2019

I released a beta version which includes this new prop. Feel free to test it and provide feedback or report bugs if you find them.

You can install it with:

npm i --save react-lazy-load-image-component@1.4.0beta.0
Read more comments on GitHub >

github_iconTop Results From Across the Web

react-router scroll to top on every transition - Stack Overflow
I have an issue when navigating into another page, its position will remain like the page before. So it won ...
Read more >
[2.0] scrollBehavior doesn't store a scrolling position on the ...
when trigger browser's back, the browser itself will scroll to original location, so, vue DON'T need to save the page's scrolling position.
Read more >
Window.scrollY - Web APIs - MDN Web Docs
The read-only scrollY property of the Window interface returns the number of pixels that the document is currently scrolled vertically.
Read more >
React scroll position after render when scrollTop is zero-Reactjs
If it doesn't work at scrollTop == 0 , then just make it always more :). It's hacky solution, but it works perfectly...
Read more >
Tracking Scroll Position With React Hooks - DEV Community ‍ ‍
Today we are going to learn, how to use JavaScript scroll event listener to track browser scroll position using hooks — React not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found