Skip to content

Commit 903514d

Browse files
committed
refactor: createRoot() instead of render() method
1 parent a0a0515 commit 903514d

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

vis/js/HeadstartRunner.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import ReactDOM from "react-dom";
33
import React from "react";
44
import { createStore } from "redux";
55
import { Provider } from "react-redux";
6+
import { createRoot } from "react-dom/client";
67

78
import rootReducer, { getInitialState } from "./reducers";
89
import {
@@ -80,11 +81,11 @@ class HeadstartRunner {
8081
}
8182

8283
renderReact() {
83-
ReactDOM.render(
84+
const rootNode: Root = createRoot(this.hsContainer);
85+
rootNode.render(
8486
<Provider store={this.store}>
8587
<Headstart />
86-
</Provider>,
87-
this.hsContainer
88+
</Provider>
8889
);
8990
}
9091

@@ -160,10 +161,7 @@ class HeadstartRunner {
160161
addWindowResizeListener() {
161162
window.addEventListener("resize", () => {
162163
const chart = getChartSize(this.config);
163-
const list = getListSize(
164-
this.config,
165-
chart.size
166-
);
164+
const list = getListSize(this.config, chart.size);
167165
this.store.dispatch(updateDimensions(chart, list));
168166
});
169167
}
@@ -195,7 +193,12 @@ class HeadstartRunner {
195193
elem?.dispatchEvent(event);
196194
}
197195

198-
rescaleMap(scaleBy: string, baseUnit: string, isContentBased: boolean, initialSort: string) {
196+
rescaleMap(
197+
scaleBy: string,
198+
baseUnit: string,
199+
isContentBased: boolean,
200+
initialSort: string
201+
) {
199202
this.config.scale_by = scaleBy;
200203
this.config.base_unit = baseUnit;
201204
this.config.content_based = isContentBased;

0 commit comments

Comments
 (0)