-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
39 lines (31 loc) · 855 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import React from 'react';
import ReactDOM from 'react-dom';
import App from './components/App';
import ErrorBoundary from './components/common/ErrorBoundary';
import registerServiceWorker from './registerServiceWorker';
export class TreeApp {
constructor() {
this.isRendered = false;
this.reactInstance = null;
}
render() {
if (!this.isRendered) {
this.reactInstance = ReactDOM.render(
<ErrorBoundary>
<App />
</ErrorBoundary>, document.getElementById('root'));
registerServiceWorker();
this.isRendered = true;
}
return this;
}
destroy() {
if (this.isRendered) {
ReactDOM.unmountComponentAtNode(document.getElementById('root'));
this.reactInstance = null;
this.isRendered = false;
}
}
}
window.component = new TreeApp();
window.component.render();