Skip to content

Commit

Permalink
Merge pull request #416 from ryandowd/master
Browse files Browse the repository at this point in the history
fix: ReactDOM.render react 18 warning
  • Loading branch information
afshinm authored Jan 14, 2024
2 parents e1a603c + f475b69 commit 3985204
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ class Grid extends Component<Partial<Config>, 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);
}

Expand Down
5 changes: 3 additions & 2 deletions src/wrapper.tsx
Original file line number Diff line number Diff line change
@@ -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<{
Expand All @@ -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() {
Expand Down

0 comments on commit 3985204

Please sign in to comment.