Skip to content

Commit 70e2990

Browse files
committed
callback added on menuclose
1 parent d3b1c44 commit 70e2990

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/useComponentVisible.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { useRef, useState, useEffect } from 'react'
22

3-
export default function useComponentVisible(initialIsVisible) {
3+
export default function useComponentVisible({
4+
initialIsVisible,
5+
onClickOutside
6+
}) {
47
const [isComponentVisible, setIsComponentVisible] = useState(initialIsVisible)
58
const ref = useRef(null)
69

@@ -15,6 +18,7 @@ export default function useComponentVisible(initialIsVisible) {
1518
document.removeEventListener('keydown', handleHideDropdown, true)
1619
document.removeEventListener('click', handleClickOutside, true)
1720
setIsComponentVisible(false)
21+
onClickOutside()
1822
}
1923
}
2024

0 commit comments

Comments
 (0)