SSE Hooks

useCallbackRef

GitHub
A custom hook that converts a callback to a ref to avoid triggering re-renders when passed as a prop or avoid re-executing effects when passed as a dependency

Installation

npx sse-hooks add use-callback-ref

Usage

example.ts
import { useCallbackRef } from "./{hooks file}";

const handleClick = useCallbackRef((event: MouseEvent) => {
  console.log("Clicked!", event);
});

useEffect(() => {
  window.addEventListener("click", handleClick);
  return () => window.removeEventListener("click", handleClick);
}, []);

API

Parameters

Prop Default Type
callback-

T

The callback function to store in a ref. It can be undefined.

Returns

Return Value Default Type
return-

T

Hook return value

Types Aliases

No specific type aliases defined for this component.

Changelog

81fa5 — feat: add useAutoSave and useCallbackRef hooks with comprehensive documentation

Built with Love • © 2026