useInert
Applies inert
to entire DOM-tree, excluding ref
and its descendants.
- @param
when
- Whether to apply theinert
attribute. - @param
ref
- The element to exclude from theinert
attribute. - @returns void
Example
const [isDialogOpen, setIsDialogOpen] = useState(false)
const dialogRef = useRef<HTMLElement>(null)
useInert(isDialogOpen, dialogRef)
return (
<Dialog ref={dialogRef} open={isDialogOpen} onClose={setIsDialogOpen} />
)