DEV Community


React Custom Hooks: Scroll Indicator

Adrian Bece
React, Frontend, Magento 2 certified developer. Magento PWA Studio contributor. Rock and metal music fan. Reads Dune, sci-fi novels and Calvin & Hobbes. Creates amazing interfaces @
・1 min read

Hello everyone, this is my first post here.

I've created this simple, but versatile React hook that keeps track of user's scroll. You can see these elements on blogs or news sites where user can keep track of how much of the article they've read.

It can keep track of scrolling of the whole page or on a certain element. It returns the percentage of the page or element scrolled (viewed).

You can find the npm package, alongside with the readme, here:

Let me know what you think or if you have any questions or comments.

Edit: I am working on an article on creating the custom React hooks. I will post is as soon as it's out. So if you are looking for a good starting point on learning the tricks of creating custom hooks, watch for my upcoming post. Thank you.

Discussion (0)