Skip to content

Commit

Permalink
Feat: 공용 모달 컴포넌트 추가 (#11)
Browse files Browse the repository at this point in the history
* Feat: 공용 모달 컴포넌트 추가

* Refactor: 불필요 코드 제거

* Refactor: 불필요 코드 제거

* Feat: layout에 Portal 위치 추가

* Refactor: 불필요 코드 제거

* Refactor: CreatePortal 임포트 방식 변경 및 포탈 성능 개선

* Refactor: 추론 가능한 타입 지정 코드 제거

* Chore: import문 띄어쓰기 수정

* Fix: 미사용 import 삭제 및 dependency list 추가

* Design: 버튼 비활성화 스타일 추가

* Refactor: ModalButton 비활성화 속성 추가

* Fix: 프리티어 줄바꿈 에러 수정
  • Loading branch information
seoyoung-min authored Feb 3, 2024
1 parent be3e7b6 commit 163ebb7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/components/ModalPortal.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { ReactNode } from 'react';
import ReactDOM from 'react-dom';
import { createPortal } from 'react-dom';

interface Props {
children: ReactNode;
}

const ModalPortal = ({ children }: Props) => {
if (typeof window === 'undefined') {
return null;
}

const el = document.getElementById('modal-root') as HTMLElement;

return ReactDOM.createPortal(children, el);
return createPortal(children, el);
};

export default ModalPortal;
2 changes: 1 addition & 1 deletion src/hooks/useBooleanOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface useBooleanOutput {
}

export default function useBooleanOutput(defaultValue?: boolean): useBooleanOutput {
const [isOn, setIsOn] = useState<boolean>(!!defaultValue);
const [isOn, setIsOn] = useState(!!defaultValue);

const toggle = useCallback(() => setIsOn((prev) => !prev), []);
const handleSetOn = useCallback(() => setIsOn(true), []);
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useOnClickOutside.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EventHandler, useEffect, useRef, useState } from 'react';
import { useEffect, useRef } from 'react';

const useOnClickOutside = (handler: () => void) => {
const ref = useRef<HTMLDivElement>(null);
Expand All @@ -15,7 +15,7 @@ const useOnClickOutside = (handler: () => void) => {
document.removeEventListener('mousedown', handleClickOutside);
document.removeEventListener('touchstart', handleClickOutside);
};
}, [ref]);
}, [ref, handler]);

return { ref };
};
Expand Down

0 comments on commit 163ebb7

Please sign in to comment.