React

I love the web, we can do anything. But well... sometime it feels like we have to do EVERYTHING.
These are pieces of code you will find useful for a React web app. Do not bother looking for a library, just copy and paste these components code.



This hook lets you add simple click and double click event to any dom element.
Never Clicked

When you click on this component, it starts a timer. If you click a second time quickly, we register a double click. If the timer ends and the user clicked once then we register a single click. Simple.
The tricky part is to find the right balance for the timeout.

With a shorter timeout:

Never Clicked

With a longer timeout:

Never Clicked

This hook is similar to useState but adds persistance thanks to local storage.
If you refresh this page the number of clicks will stay the same.

I use this for quick prototypes, when I want to store user inputs without taking out a database immediately.
I use it whena.re too: if you have not visited the Slack Integration page you will see a notification badge in the navbar. It is simple and it does not require an account.
The only limitation is due to privacy feature in some browser which might break it.