From a613a977b1a9cafaac2d10b8a62218066b587bc4 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Wed, 6 Jan 2021 13:29:31 -0300 Subject: [PATCH] Changes --- components/ui/Modal/Modal.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/components/ui/Modal/Modal.tsx b/components/ui/Modal/Modal.tsx index 746c8a5a0..070ddea63 100644 --- a/components/ui/Modal/Modal.tsx +++ b/components/ui/Modal/Modal.tsx @@ -1,4 +1,4 @@ -import { FC, useRef, useEffect } from 'react' +import { FC, useRef, useEffect, useCallback } from 'react' import Portal from '@reach/portal' import s from './Modal.module.css' import { Cross } from '@components/icons' @@ -19,11 +19,12 @@ interface Props { const Modal: FC = ({ children, open, onClose, onEnter = null }) => { const ref = useRef() as React.MutableRefObject - const handleKey = (e: KeyboardEvent) => { - if (e.key === 'Escape') { - return onClose() - } - } + const handleKey = (e: KeyboardEvent) => + useCallback(() => { + if (e.key === 'Escape') { + return onClose() + } + }, [onClose]) useEffect(() => { if (ref.current) {