mirror of
https://github.com/filecoin-project/slate.git
synced 2024-12-25 18:13:10 +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;
|
|
};
|