← tags
writing
react
useNetworkStatus: react to online/offline
A custom hook that listens to window online/offline events and returns a boolean.
useMouseCoords: track cursor position
A custom hook that subscribes to mousemove and returns the latest clientX and clientY.
useLocalStorage: persist React state in localStorage
A small custom hook that reads and writes JSON to localStorage, with lazy initialization on first render.
Custom React hooks: a three-part series
Three small hooks I wrote in 2023: localStorage persistence, mouse coordinates, and online/offline status. Code-first, no fluff.