Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. ๐ซ Status page with uptime monitoring & API monitoring as code ๐ซ openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor
Something went wrong. Try again.
1.1 kB ยท 36 lines
TypeScript
12345678910111213141516171819202122232425262728293031323334353637// @see https://github.com/radix-ui/primitives/blob/main/packages/react/compose-refs/src/composeRefs.tsx
import * as React from "react";
type PossibleRef<T> = React.Ref<T> | undefined;
/** * Set a given ref to a given value * This utility takes care of different types of refs: callback refs and RefObject(s) */function setRef<T>(ref: PossibleRef<T>, value: T) { if (typeof ref === "function") { ref(value); } else if (ref !== null && ref !== undefined) { (ref as React.MutableRefObject<T>).current = value; }}
/** * A utility to compose multiple refs together * Accepts callback refs and RefObject(s) */function composeRefs<T>(...refs: PossibleRef<T>[]) { return (node: T) => refs.forEach((ref) => setRef(ref, node));}
/** * A custom hook that composes multiple refs * Accepts callback refs and RefObject(s) */function useComposedRefs<T>(...refs: PossibleRef<T>[]) { // eslint-disable-next-line react-hooks/exhaustive-deps return React.useCallback(composeRefs(...refs), refs);}
export { composeRefs, useComposedRefs };