mirror of
https://github.com/filecoin-project/slate.git
synced 2024-11-27 10:52:41 +03:00
0c4ecd9025
- feat(_document): render portals in the div element with id browser_extension - feat(ModalPortal): useReactDom.createPortal to render childrens
15 lines
375 B
JavaScript
15 lines
375 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(children, document.getElementById("modals_portal")) : null;
|
|
};
|