Fix useCallback (#152)

This commit is contained in:
B 2021-01-09 12:43:43 -03:00 committed by GitHub
parent 8698794c96
commit 8d489bf665
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,12 +19,14 @@ interface Props {
const Modal: FC<Props> = ({ children, open, onClose, onEnter = null }) => {
const ref = useRef() as React.MutableRefObject<HTMLDivElement>
const handleKey = (e: KeyboardEvent) =>
useCallback(() => {
const handleKey = useCallback(
(e: KeyboardEvent) => {
if (e.key === 'Escape') {
return onClose()
}
}, [onClose])
},
[onClose]
)
useEffect(() => {
if (ref.current) {