MCPcopy Index your code
hub / github.com/react/react / Dialog

Function Dialog

fixtures/flight-parcel/src/Dialog.tsx:5–21  ·  view source on GitHub ↗
({
  trigger,
  children,
}: {
  trigger: ReactNode;
  children: ReactNode;
})

Source from the content-addressed store, hash-verified

3import {ReactNode, useRef} from 'react';
4
5export function Dialog({
6 trigger,
7 children,
8}: {
9 trigger: ReactNode;
10 children: ReactNode;
11}) {
12 let ref = useRef<HTMLDialogElement | null>(null);
13 return (
14 <>
15 <button onClick={() => ref.current?.showModal()}>{trigger}</button>
16 <dialog ref={ref} onSubmit={() => ref.current?.close()}>
17 {children}
18 </dialog>
19 </>
20 );
21}

Callers

nothing calls this directly

Calls 2

useRefFunction · 0.90
closeMethod · 0.65

Tested by

no test coverage detected