We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d3b1c44 commit 70e2990Copy full SHA for 70e2990
src/useComponentVisible.jsx
@@ -1,6 +1,9 @@
1
import { useRef, useState, useEffect } from 'react'
2
3
-export default function useComponentVisible(initialIsVisible) {
+export default function useComponentVisible({
4
+ initialIsVisible,
5
+ onClickOutside
6
+}) {
7
const [isComponentVisible, setIsComponentVisible] = useState(initialIsVisible)
8
const ref = useRef(null)
9
@@ -15,6 +18,7 @@ export default function useComponentVisible(initialIsVisible) {
15
18
document.removeEventListener('keydown', handleHideDropdown, true)
16
19
document.removeEventListener('click', handleClickOutside, true)
17
20
setIsComponentVisible(false)
21
+ onClickOutside()
22
}
23
24
0 commit comments