Skip to content

Commit 8503518

Browse files
committed
fix(useDialogContainer): pass DialogContainer props * 2
1 parent d03be5e commit 8503518

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

.changeset/eight-pumas-happen.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cube-dev/ui-kit': patch
3+
---
4+
5+
Fixes false error in useDialogContainer.

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,25 @@ export function useDialogContainer<
2525
const [containerProps, setContainerProps] = useState<E | null>(null);
2626
const setupRef = useRef(false);
2727

28-
// 'open' accepts props required by the Component and opens the dialog
29-
const open = useEvent((props: P, containerProps?: E) => {
28+
function setupCheck() {
3029
if (!setupRef.current) {
3130
throw new Error(
3231
'useDialogContainer: DialogContainer must be rendered. Use `rendered` property to include it in your component tree.',
3332
);
3433
}
34+
}
35+
36+
// 'open' accepts props required by the Component and opens the dialog
37+
const open = useEvent((props: P, containerProps?: E) => {
38+
setupCheck();
3539

3640
setComponentProps(props);
3741
setContainerProps(containerProps ?? null);
3842
setIsOpen(true);
3943
});
4044

4145
const update = useEvent((props: P, containerProps?: E) => {
42-
if (!setupRef.current) {
43-
throw new Error(
44-
'useDialogContainer: DialogContainer must be rendered. Use `rendered` property to include it in your component tree.',
45-
);
46-
}
46+
setupCheck();
4747

4848
setComponentProps(props);
4949
setContainerProps(containerProps ?? null);

0 commit comments

Comments
 (0)