useLogger
Development helper that logs a component's mount, update, and unmount lifecycle to the console.
useLogger logs a component's lifecycle to the console — useful for spotting unexpected re-renders or verifying an effect's cleanup runs when you expect it to:
<name> mounted— once, on mount, alongside the given values<name> updated— on every change ofprops<name> unmounted— on cleanup
import { useLogger } from '@42/ui-react';
function Demo({ count, open }: { count: number; open: boolean }) {
useLogger('Demo', [count, open]);
// ...
}props is compared by the effect's dependency array, so pass the values themselves (useLogger("Demo", [count, open])) rather than a fresh object literal — an inline { count, open } would be a new reference on every render and log an "updated" on every single one.
Usage
Open the browser console, then click the button — you'll see a mounted log on load and an updated log on every click.
Open the console, then click.
Code
function Demo() { const [count, setCount] = useState(0); useLogger('Demo', [count]); return <Button onClick={() => setCount((c) => c + 1)}>Clicked {count} times</Button>;}API
Prop
Type
Always returns null.
useLocalStorage
Persists a piece of state to localStorage, kept in sync across every component using the same key — within the tab and across tabs.
useContainerQuery
Tracks whether a container element's width is below a threshold, updating live via ResizeObserver — the container-query counterpart to useMediaQuery.