Skip to content

Commit 7b18b49

Browse files
committed
feat(Dialog): add useDialogContainer hook * 2
1 parent 7c9fa59 commit 7b18b49

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

src/components/overlays/Dialog/dialog-container.tsx

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,9 @@
1-
import React, { useState, useMemo, ReactElement } from 'react';
1+
import React, { useState, useMemo } from 'react';
22

33
import { useEvent } from '../../../_internal/index';
44

55
import { DialogContainer } from './DialogContainer';
66

7-
// Overload for dialogs that expect no props
8-
export function useDialogContainer(Component: React.ComponentType<{}>): {
9-
open: () => void;
10-
close: () => void;
11-
rendered: ReactElement | null;
12-
};
13-
14-
// Overload for dialogs that require props
15-
export function useDialogContainer<P>(Component: React.ComponentType<P>): {
16-
open: (props: P) => void;
17-
close: () => void;
18-
rendered: ReactElement | null;
19-
};
20-
217
/**
228
* Generic hook to manage a dialog component.
239
*
@@ -30,7 +16,7 @@ export function useDialogContainer<P>(Component: React.ComponentType<P>) {
3016

3117
// 'open' accepts props required by the Component and opens the dialog
3218
const open = useEvent((props: P) => {
33-
setComponentProps(props === undefined ? ({} as P) : props);
19+
setComponentProps(props);
3420
setIsOpen(true);
3521
});
3622

0 commit comments

Comments
 (0)