mirror of
https://github.com/supabase/supabase.git
synced 2026-07-04 18:34:26 +08:00
12 lines
302 B
TypeScript
12 lines
302 B
TypeScript
import * as React from 'react'
|
|
|
|
export function useFocusRef<T extends HTMLOrSVGElement>(isCellSelected: boolean) {
|
|
const ref = React.useRef<T>(null)
|
|
React.useLayoutEffect(() => {
|
|
if (!isCellSelected) return
|
|
ref.current?.focus({ preventScroll: true })
|
|
}, [isCellSelected])
|
|
|
|
return ref
|
|
}
|