Skip to content

Commit 295ca3a

Browse files
committed
Minor update to React 18 syntax
1 parent 509f3df commit 295ca3a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

extension/src/main.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
2-
import ReactDOM from 'react-dom';
2+
import { createRoot } from 'react-dom/client';
3+
34

45
import { Provider } from 'react-redux';
56

@@ -23,10 +24,11 @@ const Main = function () {
2324
};
2425

2526
window.reactMain = function () {
26-
ReactDOM.render(
27-
<Main />,
28-
document.getElementsByClassName('magicss-command-palette-root')[0]
29-
);
27+
// https://reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html
28+
const container = document.getElementsByClassName('magicss-command-palette-root')[0];
29+
const root = createRoot(container); // createRoot(container!) if you use TypeScript
30+
31+
root.render(<Main />);
3032
};
3133

3234
window.reactMain();

0 commit comments

Comments
 (0)