rehooks / window-scroll-position Goto Github PK
View Code? Open in Web Editor NEWReact hook for Window scroll position
License: MIT License
React hook for Window scroll position
License: MIT License
The PR #5 introduced a handleScroll.cancel()
but there is no property cancel
on the handler function. So, on component unmount, an error is thrown and thus the removeEventListener
is never called.
Hey, is this not production ready? I tried to install on npm, and no dice.
npm ERR! code E404
npm ERR! 404 Not Found: @rehooks/window-scroll-position@latest
I was reading the hook source code and I was wondering if it really needs to specify {passive: true}
. The scroll
event should be passive by default since it cannot be cancelled. Check the last paragraph:
You don't need to worry about the value of passive for the basic scroll event. Since it can't be canceled, event listeners can't block page rendering anyway.
Building for production environment:
ERROR in ....js from UglifyJs
Unexpected token: punc ({) [./node_modules/@rehooks/window-scroll-position/index.js:2,0]
Great util guys! Im super excited about hooks!
I was working on something with a scroll listener and I came across MDN example.
MDN scroll event throttling
hook Implementation:
https://codepen.io/bmgaynor/pen/aXWzEa
Let me know what you guys think.
Tried to use this with next.js, which has SSR out-of-the-box.
I am getting the window is not defined
error. Consider running code that uses window from useEffect hooks, so they only run on the client.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.