forked from crowetic/commerce
Fix useCallback
This commit is contained in:
parent
66b8bdb6bb
commit
e593eab9cc
@ -19,12 +19,14 @@ interface Props {
|
|||||||
const Modal: FC<Props> = ({ children, open, onClose, onEnter = null }) => {
|
const Modal: FC<Props> = ({ children, open, onClose, onEnter = null }) => {
|
||||||
const ref = useRef() as React.MutableRefObject<HTMLDivElement>
|
const ref = useRef() as React.MutableRefObject<HTMLDivElement>
|
||||||
|
|
||||||
const handleKey = (e: KeyboardEvent) =>
|
const handleKey = useCallback(
|
||||||
useCallback(() => {
|
(e: KeyboardEvent) => {
|
||||||
if (e.key === 'Escape') {
|
if (e.key === 'Escape') {
|
||||||
return onClose()
|
return onClose()
|
||||||
}
|
}
|
||||||
}, [onClose])
|
},
|
||||||
|
[onClose]
|
||||||
|
)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (ref.current) {
|
if (ref.current) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user