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