반응형
const SignUp = ({setShowModal}) => {
// let modalClose = useRef();
const handleCloseModal = () => {
setShowModal(false);
}
// useEffect(() => {
// document.addEventListener("mousedown", (event)=>{
// if(!modalClose.current.contains(event.target)){
// }
// })
// })
import OutsideClickHandler from 'react-outside-click-handler';
<OutsideClickHandler
onOutsideClick={() => {
handleCloseModal();
}}
>
</OutsideClickHandler>
contains 계속 안먹혀서 진짜 고생했는데
저거 하나만 써도 모달 밖에 클릭하면 바로 닫힘
짱짱
반응형
'TIL' 카테고리의 다른 글
[TIL] 21.10.25. (0) | 2021.10.26 |
---|---|
[TIL] 21.10.22. (0) | 2021.10.23 |
[TIL] 21.10.20. (0) | 2021.10.21 |
[TIL] 21.10.19. (0) | 2021.10.19 |
[TIL] 21.10.18. (0) | 2021.10.18 |
댓글