MCPcopy Index your code
hub / github.com/code100x/cms / useModal

Function useModal

src/hooks/useModal.tsx:3–21  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1import { useRef } from 'react';
2
3const useModal = () => {
4 const ref = useRef<HTMLDialogElement>(null);
5
6 const onOpen = () => {
7 const currentDialog = ref.current;
8 if (currentDialog) {
9 currentDialog.showModal();
10 }
11 };
12
13 const onClose = () => {
14 const currentDialog = ref.current;
15 if (currentDialog) {
16 currentDialog.close();
17 }
18 };
19
20 return { ref, onOpen, onClose };
21};
22
23export default useModal;

Callers 1

NewPostDialogFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected