mirror of
https://github.com/filecoin-project/slate.git
synced 2024-12-24 17:44:50 +03:00
20 lines
457 B
JavaScript
20 lines
457 B
JavaScript
import * as React from "react";
|
|
import * as ReactDOM from "react-dom";
|
|
|
|
export const ModalPortal = ({ children }) => {
|
|
const [mounted, setMounted] = React.useState(false);
|
|
|
|
React.useEffect(() => {
|
|
setMounted(true);
|
|
|
|
return () => setMounted(false);
|
|
}, []);
|
|
|
|
return mounted
|
|
? ReactDOM.createPortal(
|
|
<div onClick={(e) => e.stopPropagation()}>{children}</div>,
|
|
document.getElementById("modals_portal")
|
|
)
|
|
: null;
|
|
};
|