Files
SupportBot-Dashboard/dashboard/src/hooks/use-forwarded-ref.ts
T
Char b82f69783d Add dashboard UI source and track it in the repository.
Expose the Vite/React website source under dashboard/ (with node_modules still ignored) so the full dashboard can be built and maintained from this repo.
2026-07-26 13:09:19 +01:00

17 lines
397 B
TypeScript

import { useEffect, useRef, type ForwardedRef } from "react";
export function useForwardedRef<T>(forwardedRef: ForwardedRef<T>) {
const innerRef = useRef<T>(null);
useEffect(() => {
if (!forwardedRef) return;
if (typeof forwardedRef === "function") {
forwardedRef(innerRef.current);
} else {
forwardedRef.current = innerRef.current;
}
});
return innerRef;
}