import { useState } from 'react' ; import { _document } from '../_ssr.config' ; import { useEventListener } from '../useEventListener' ; returns export function useActiveElement ( ) { const [ activeElement , setActiveElement ] = useState ( ( ) => _document ?. activeElement ) ; useEventListener ( 'focus' , ( ) => setActiveElement ( _document ?. activeElement ) , true ) ; useEventListener ( 'blur' , ( ) => setActiveElement ( null ) , true ) ; return { activeElement } ; }