@slango/reazione
v1.0.8
Published
Collection of generic react utilities
Downloads
1,119
Readme
Reazione (@slango/reazione)
Collection of generic react utilities ("reazione" is Italian for reaction).
Installation
pnpm add @slango/reazioneRequires react ^19 as a peer dependency.
Hooks (@slango/reazione/hooks/*)
useDebouncedCallback— debounced wrapper around a callback withrun/canceland unmount cleanup.useMounted—falseduring SSR/hydration,trueafter mount.useClickOutside— invoke a handler when clicking outside an element.useClientValue— resolve a client-only value after hydration without mismatches.usePreventScrolling— lock background scroll, compensating for the scrollbar width.useScrollEdge— debounced notification when scrolling approaches an edge.
Usage
import { useDebouncedCallback } from '@slango/reazione/hooks/useDebouncedCallback';
const Search = ({ onSearch }: { onSearch: (term: string) => void }) => {
const debounced = useDebouncedCallback(onSearch, 300);
return <input onChange={(e) => debounced.run(e.target.value)} />;
};import { Edge, useScrollEdge } from '@slango/reazione/hooks/useScrollEdge';
useScrollEdge({ edge: Edge.BOTTOM, onEdgeReached: loadNextPage });Testing
Run linting and unit tests:
pnpm lint
pnpm testContributing
Issues and pull requests are welcome.
