mirror of
https://github.com/vercel/commerce.git
synced 2025-07-25 19:21:23 +00:00
Ran prettier fix
This commit is contained in:
@@ -7,32 +7,36 @@ interface ClickOutsideProps {
|
||||
children: any
|
||||
}
|
||||
|
||||
const ClickOutside = ({ active = true, onClick, children }: ClickOutsideProps) => {
|
||||
const innerRef = useRef()
|
||||
const ClickOutside = ({
|
||||
active = true,
|
||||
onClick,
|
||||
children,
|
||||
}: ClickOutsideProps) => {
|
||||
const innerRef = useRef()
|
||||
|
||||
const handleClick = (event: any) => {
|
||||
if (!hasParent(event.target, innerRef?.current)) {
|
||||
if (typeof onClick === 'function') {
|
||||
onClick(event)
|
||||
}
|
||||
const handleClick = (event: any) => {
|
||||
if (!hasParent(event.target, innerRef?.current)) {
|
||||
if (typeof onClick === 'function') {
|
||||
onClick(event)
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (active) {
|
||||
document.addEventListener('mousedown', handleClick)
|
||||
document.addEventListener('touchstart', handleClick)
|
||||
}
|
||||
|
||||
return () => {
|
||||
if (active) {
|
||||
document.removeEventListener('mousedown', handleClick)
|
||||
document.removeEventListener('touchstart', handleClick)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return React.cloneElement(children, { ref: innerRef })
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (active) {
|
||||
document.addEventListener('mousedown', handleClick)
|
||||
document.addEventListener('touchstart', handleClick)
|
||||
}
|
||||
|
||||
return () => {
|
||||
if (active) {
|
||||
document.removeEventListener('mousedown', handleClick)
|
||||
document.removeEventListener('touchstart', handleClick)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return React.cloneElement(children, { ref: innerRef })
|
||||
}
|
||||
|
||||
export default ClickOutside
|
||||
|
Reference in New Issue
Block a user