DEV Community

Adrian Bece
Adrian Bece

Posted on

4 1

React Custom Hooks: Scroll Indicator

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: https://www.npmjs.com/package/react-use-scroll-indicator

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.

Please leave your appreciation by commenting on this post!

Of course, only if it was helpful.

Sure thing!

Top comments (0)

typescript

11 Tips That Make You a Better Typescript Programmer

1 Think in {Set}

Type is an everyday concept to programmers, but it’s surprisingly difficult to define it succinctly. I find it helpful to use Set as a conceptual model instead.

#2 Understand declared type and narrowed type

One extremely powerful typescript feature is automatic type narrowing based on control flow. This means a variable has two types associated with it at any specific point of code location: a declaration type and a narrowed type.

#3 Use discriminated union instead of optional fields

...

Read the whole post now!

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay