Skip to content

Commit 9db6790

Browse files
LukaFilipovic99jtomic-croz
authored andcommitted
#235 Make argument of Modal onOpen function optional
1 parent 130831b commit 9db6790

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

libs/alert/src/Modal.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export type UseModal<T = unknown> = {
109109
* Function for opening the modal. Called upon a variable initialized with 'useModal()'.
110110
* Most often used in onClick functions (ex. inside the onClick prop of the Button component)
111111
*/
112-
onOpen: (value: T | null) => void;
112+
onOpen: (value?: T | null) => void;
113113

114114
/**
115115
* Used for fetching or storing the state of the modal. Called upon a variable initialized with 'useModal()'.
@@ -130,9 +130,9 @@ export function useModal<T = unknown>(): UseModal<T> {
130130
const [isOpen, setIsOpen] = React.useState(false);
131131
const [state, setState] = React.useState<T | null>(null);
132132

133-
const onOpen = (value: T | null) => {
133+
const onOpen = (value?: T | null) => {
134134
setIsOpen(true);
135-
setState(value);
135+
setState(value ? value : null);
136136
};
137137

138138
const onClose = () => setIsOpen(false);

0 commit comments

Comments
 (0)