Skip to content

Commit 6599f9e

Browse files
fix eslint warning and errors
1 parent e5d9c13 commit 6599f9e

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

src/components/Popup.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
// eslint-disable-next-line eslint-comments/disable-enable-pair
2+
/* eslint-disable react-hooks/rules-of-hooks */
13
'use client'
24

35
import React, {
46
forwardRef,
7+
useCallback,
58
useEffect,
69
useImperativeHandle,
710
useRef,
@@ -15,7 +18,7 @@ import Transition from './Transition'
1518
import { DefaultConfig } from '../utils/constant'
1619

1720
type PopupPropsExtended = PopupProps & {
18-
onClickClose?: (isClose: Boolean) => void
21+
onClickClose?: (isClose: boolean) => void
1922
}
2023

2124
const Popup = forwardRef<PopupHandle, PopupPropsExtended>(
@@ -44,11 +47,11 @@ const Popup = forwardRef<PopupHandle, PopupPropsExtended>(
4447
close: () => setIsOpen(false),
4548
}))
4649

47-
const handleClose = () => {
50+
const handleClose = useCallback(() => {
4851
onClickClose && onClickClose(false)
4952
onClose && onClose()
5053
setIsOpen(false)
51-
}
54+
}, [onClose, onClickClose])
5255

5356
useEffect(() => {
5457
setIsOpen(open)
@@ -62,7 +65,7 @@ const Popup = forwardRef<PopupHandle, PopupPropsExtended>(
6265
clearTimeout(timer)
6366
}
6467
}
65-
}, [open])
68+
}, [open, autoClose, onClose, onClickClose, handleClose])
6669

6770
closeOnOutsideClick && useOutsideClick(rootRef, handleClose)
6871
closeOnEscape && useEscapeKey(handleClose)
@@ -97,4 +100,6 @@ const Popup = forwardRef<PopupHandle, PopupPropsExtended>(
97100
}
98101
)
99102

103+
Popup.displayName = 'Popup'
104+
100105
export default Popup

src/components/PopupContainer.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
'use client'
22

3-
import React from 'react'
3+
import React, { forwardRef, useEffect, useRef, useState } from 'react'
44
import ReactDOM from 'react-dom'
55
import Popup from './Popup'
66
import { PopupContainerProps, PopupHandle, defualtProps } from '../type'
77
import '../styles/index.scss'
8-
import { forwardRef, useEffect, useRef, useState } from 'react'
8+
99
import { DefaultConfig } from '../utils/constant'
1010

1111
const defaultProps: defualtProps = {
@@ -60,4 +60,6 @@ const PopupContainer = forwardRef<HTMLDivElement, PopupContainerProps>(
6060
}
6161
)
6262

63+
PopupContainer.displayName = 'PopupContainer'
64+
6365
export default PopupContainer

src/components/Transition.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const Transition: React.FC<TransitionProps> = ({
3434
if (inProp) {
3535
startEnterAnimation()
3636
}
37-
}, [inProp])
37+
}, [inProp, onEntered, duration, enterClassName])
3838

3939
useEffect(() => {
4040
const node = nodeRef.current!
@@ -56,7 +56,7 @@ const Transition: React.FC<TransitionProps> = ({
5656
if (!inProp) {
5757
startLeaveAnimation()
5858
}
59-
}, [inProp])
59+
}, [inProp, onExited, duration, leaveClassName])
6060

6161
return <div ref={nodeRef}>{children}</div>
6262
}

src/hooks/useOutsideClick.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function useOutsideClick(
2020
return () => {
2121
document.removeEventListener('mousedown', handleClickOutside)
2222
}
23-
}, [ref])
23+
}, [ref, handleClickOutsideCallback])
2424
}
2525

2626
export default useOutsideClick

0 commit comments

Comments
 (0)