diff --git a/src/grid.tsx b/src/grid.tsx index e990b84..c790656 100644 --- a/src/grid.tsx +++ b/src/grid.tsx @@ -18,6 +18,11 @@ class Grid extends Component, any> { } componentDidMount(): void { + // prevent gridjs from complaining that the container is not empty + if (this.wrapper.current.childNodes.length > 0) { + this.wrapper.current.innerHTML = ''; + } + this.instance.render(this.wrapper.current); } diff --git a/src/wrapper.tsx b/src/wrapper.tsx index 1656e50..59e39cc 100644 --- a/src/wrapper.tsx +++ b/src/wrapper.tsx @@ -1,5 +1,5 @@ import { h, createRef as gCreateRef, Component as gComponent } from "gridjs"; -import ReactDOM from "react-dom"; +import { createRoot } from "react-dom/client"; export class ReactWrapper extends gComponent<{ @@ -13,7 +13,8 @@ export class ReactWrapper extends gComponent<{ ref = gCreateRef(); componentDidMount(): void { - ReactDOM.render(this.props.element, this.ref.current); + const root = createRoot(this.ref.current); + root.render(this.props.element); } render() {