UNPKG

@equinor/eds-utils

Version:

Utility functions and hooks for the Equinor Design System

15 lines (12 loc) 351 B
import { useState, useEffect } from 'react'; const useIsInDialog = el => { const [inDialog, setInDialog] = useState(null); useEffect(() => { if (el && inDialog === null) { setInDialog(!!el.closest('dialog')); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [el]); return inDialog; }; export { useIsInDialog };