simonmon8692
simonmon8692
PD🧩 Plasmo Developers
Created by simonmon8692 on 7/17/2023 in #👟framework
Create CSUI root containers programmatically
Thanks for the quick help. I managed to do what I wanted with your tip. For anyone who is interested how I did it:
// MyComponent.tsx
function MyComponent(props: MyProps) {
return(<div>...</div>)
}
export default MyComponent
// MyComponent.tsx
function MyComponent(props: MyProps) {
return(<div>...</div>)
}
export default MyComponent
// content.ts
import React from "react"
import { createRoot } from "react-dom/client"
...
// first creation of component
const container = document.createElement("div")
anchorInDom.prepend(container)
const root = createRoot(container)
root.render(React.createElement(MyComponent, props))
...
// update component
root.render(React.createElement(MyComponent, otherProps))
// content.ts
import React from "react"
import { createRoot } from "react-dom/client"
...
// first creation of component
const container = document.createElement("div")
anchorInDom.prepend(container)
const root = createRoot(container)
root.render(React.createElement(MyComponent, props))
...
// update component
root.render(React.createElement(MyComponent, otherProps))
7 replies