This commit is contained in:
Quan HL
2023-09-25 14:12:05 +07:00
parent ded3808ffe
commit 82439cca83

View File

@@ -64,16 +64,8 @@ export const ContentApp = () => {
); );
}; };
// Create a new div as an extension root // Create a new div and attach it to the DOM
const extensionRoot = document.createElement("div"); const root = document.createElement("div");
document.body.appendChild(extensionRoot); document.body.appendChild(root);
// Create a shadow root ReactDOM.render(<ContentApp />, root);
const shadowRoot = extensionRoot.attachShadow({ mode: "open" });
// Now we create a mount point in the Shadow DOM
const reactRoot = document.createElement("div");
shadowRoot.appendChild(reactRoot);
// Render React App inside our shadow root within the mount point.
ReactDOM.render(<ContentApp />, reactRoot);