Skip to content

Commit

Permalink
Refactor: CreatePortal 임포트 방식 변경 및 포탈 성능 개선
Browse files Browse the repository at this point in the history
  • Loading branch information
seoyoung-min authored Feb 2, 2024
1 parent 12fc904 commit f63caee
Showing 1 changed file with 6 additions and 2 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;

0 comments on commit f63caee

Please sign in to comment.