HOC doesn't track scroll position - `scrollPosition` is always `null`
See original GitHub issueBug 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:
- Created 4 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Right, as @FacundoMainere said if your browser supports
IntersectionObserver
, the HOC doesn’t passtrackScrollPosition
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.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: