Skip to content

Commit 3985204

Browse files
authored
Merge pull request #416 from ryandowd/master
fix: ReactDOM.render react 18 warning
2 parents e1a603c + f475b69 commit 3985204

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/grid.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ class Grid extends Component<Partial<Config>, any> {
1818
}
1919

2020
componentDidMount(): void {
21+
// prevent gridjs from complaining that the container is not empty
22+
if (this.wrapper.current.childNodes.length > 0) {
23+
this.wrapper.current.innerHTML = '';
24+
}
25+
2126
this.instance.render(this.wrapper.current);
2227
}
2328

src/wrapper.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { h, createRef as gCreateRef, Component as gComponent } from "gridjs";
2-
import ReactDOM from "react-dom";
2+
import { createRoot } from "react-dom/client";
33

44

55
export class ReactWrapper extends gComponent<{
@@ -13,7 +13,8 @@ export class ReactWrapper extends gComponent<{
1313
ref = gCreateRef();
1414

1515
componentDidMount(): void {
16-
ReactDOM.render(this.props.element, this.ref.current);
16+
const root = createRoot(this.ref.current);
17+
root.render(this.props.element);
1718
}
1819

1920
render() {

0 commit comments

Comments
 (0)