1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-18 09:35:20 +02:00
joplin/packages/app-desktop/gui/hooks/useDocument.ts
Henry Heino 4a88d6ff7a
Desktop: Multiple window support (#11181)
Co-authored-by: Laurent Cozic <laurent22@users.noreply.github.com>
2024-11-08 15:32:05 +00:00

13 lines
407 B
TypeScript

import { useMemo } from 'react';
// Returns the Document that contains [elementRef]. This is useful when a component
// can be rendered in secondary windows and needs to access the component's container
// document.
const useDocument = (elementRef: Element|null) => {
return useMemo(() => {
return (elementRef ?? null)?.getRootNode() as Document|null;
}, [elementRef]);
};
export default useDocument;