useCleanId | (): string | React's useId with only letters and digits, safe in an id, a selector and an anchor (React's own has colons). |
|---|
useHydrated | (): boolean | False on the server and in the render that hydrates; true after, and at once for a part first drawn in the browser. |
|---|
useMedia | (query: string, serverValue?: boolean): boolean | Whether a media query matches; serverValue (false) on the server and while hydrating. |
|---|
usePrefersReducedMotion | (): boolean | True when the reader asked for less motion. A script-driven motion checks it; CSS motion sits in its own media query. |
|---|
useBrowserZone | <T extends string | null>(fallback: T): string | T | The browser's time zone once hydrated; fallback (the server's) until then. |
|---|
useRemembered | (key: string): [string | null, (value: string | null) => void] | A value remembered in this browser under key (null on the server, while hydrating, or when none is kept) and its setter (null forgets it). Every reader of the key on the page, and in other tabs, follows a change. Where storage is refused it is kept for this page only. |
|---|
useNow | (ms?: number, serverNow?: number): number | The time now, in milliseconds, ticking every ms (30 s) once the page is live; 0 on the server and while hydrating, so a time measured against it says the same words in both renders. Pass the server's own read time as serverNow to draw against it until the clock starts. |
|---|
useShownFor | <T>(result: T | null | undefined, ms: number, clears?: (result: T) => boolean): [shown: T | undefined, hide: () => void] | A result shown for ms after it arrives, then gone: "Saved", "Copied", a bulk action's count. Returns the result while it shows (undefined after) and a function that hides it now (a close button). A new result (another object) shows again. clears picks the results that go on their own; the rest (a failure, usually) stay until hidden or replaced. The hook remembers the one it hid, so a re-render does not bring it back. |
|---|
useIsoLayoutEffect | (effect: EffectCallback, deps?: DependencyList | undefined): void | useLayoutEffect in the browser, useEffect on the server, where a layout effect never runs and React warns about it: for a measure or a write that must land before paint. |
|---|
cn | (...parts: (string | false | null | undefined)[]): string | Small helpers every React app in the network wrote its own copy of. No framework here: the React hooks are in hooks.react.tsx. Joins class names, dropping the empty ones: cn("cap-btn", busy && "is-busy"). No merging. |
|---|
clamp | (n: number, lo: number, hi: number): number | n held to lo to hi; where hi is under lo, lo. |
|---|
listText | (words: readonly string[], join?: "and" | "or"): string | "A, B, and C" (and "A and B"; "A, B, or C" with "or"): the platform's own list, in American English with its serial comma. |
|---|
reducedMotion | (): boolean | The reader asks for reduced motion (false where there is no window: a server, a test). |
|---|
uid | (prefix: string): string | A new id on every call, prefix-1, prefix-2: for a part a script gives an id to. |
|---|
readStored | (key: string): string | null | |
|---|
writeStored | (key: string, value: string | null): void | Stores a value (null forgets it) and tells every reader on the page. |
|---|
subscribeStored | (listener: () => void): () => void | Calls listener when a stored value changes here or in another tab. |
|---|