Skip to content

Instantly share code, notes, and snippets.

@YarnSphere
YarnSphere / useCombinedRef.ts
Last active September 29, 2025 09:56
Hook for combining references, compatible with React 19
// SPDX-FileCopyrightText: 2025 YarnSphere
// SPDX-License-Identifier: MIT
import * as React from "react";
type Ref<T> = NonNullable<React.Ref<T>>;
type Cleanups<T> = Map<React.RefCallback<T>, () => void>;
/**
* Combines multiple references into a single stable callback reference while