mirror of
https://github.com/ruvnet/RuVector.git
synced 2026-05-25 06:36:37 +00:00
Major additions: - Complete Next.js studio application with 1600+ components - Docker support (Dockerfile.combined, docker-compose.yml) - GCP deployment documentation and benchmarks - SQL benchmark scripts for performance testing - Sentry integration for monitoring - Comprehensive test suite and mocks Studio features: - Dashboard and admin interfaces - Data visualization components - Authentication and user management - API integration with RuVector backend - Static data and public assets 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
32 lines
920 B
TypeScript
32 lines
920 B
TypeScript
import { Ref, useCallback } from 'react'
|
|
|
|
type PossibleRef<T> = 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)
|
|
*/
|
|
export 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)
|
|
*/
|
|
export function useComposedRefs<T>(...refs: PossibleRef<T>[]) {
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
return useCallback(composeRefs(...refs), refs)
|
|
}
|