mirror of
https://github.com/aljazceru/landscape-template.git
synced 2026-01-28 18:54:35 +01:00
feat: refactor project structure
Refactored the project structure so that each page has its own tree of components and a global "Components" folder for the components that is used by more than one page. - Added an "assets" directory that exports all static images/icons/fonts/...etc
This commit is contained in:
17
src/Components/Portal/Portal.jsx
Normal file
17
src/Components/Portal/Portal.jsx
Normal file
@@ -0,0 +1,17 @@
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
|
||||
export const Portal = ({ children, className = "root-portal", el = "div" }) => {
|
||||
const [container] = React.useState(document.createElement(el));
|
||||
|
||||
container.classList.add(className);
|
||||
|
||||
React.useEffect(() => {
|
||||
document.body.appendChild(container);
|
||||
return () => {
|
||||
document.body.removeChild(container);
|
||||
};
|
||||
}, [container]);
|
||||
|
||||
return ReactDOM.createPortal(children, container);
|
||||
};
|
||||
Reference in New Issue
Block a user