aboutsummaryrefslogtreecommitdiff
path: root/core/search-component/src/main/components/root.tsx
diff options
context:
space:
mode:
authorMaksymilian Pamula <mpamula@virtuslab.com>2020-04-22 06:46:36 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-06-04 11:25:34 +0200
commit4065a65fe3294e0ddf54f5756380f7dc1aa032b2 (patch)
tree3f225828db0430f478f1db9650c9c2d858d6bfa8 /core/search-component/src/main/components/root.tsx
parent7674ce23f132f727b71545ad3aa62be5059613d6 (diff)
downloaddokka-4065a65fe3294e0ddf54f5756380f7dc1aa032b2.tar.gz
dokka-4065a65fe3294e0ddf54f5756380f7dc1aa032b2.tar.bz2
dokka-4065a65fe3294e0ddf54f5756380f7dc1aa032b2.zip
TD: Rewrite application to TS
Diffstat (limited to 'core/search-component/src/main/components/root.tsx')
-rw-r--r--core/search-component/src/main/components/root.tsx43
1 files changed, 43 insertions, 0 deletions
diff --git a/core/search-component/src/main/components/root.tsx b/core/search-component/src/main/components/root.tsx
new file mode 100644
index 00000000..70ed9550
--- /dev/null
+++ b/core/search-component/src/main/components/root.tsx
@@ -0,0 +1,43 @@
+import React from 'react';
+import {render} from 'react-dom';
+import RedBox from 'redbox-react';
+
+import App from "./app";
+import './app/index.scss';
+
+const appEl = document.getElementById('searchBar');
+const rootEl = document.createElement('div');
+
+let renderApp = () => {
+ render(
+ <App/>,
+ rootEl
+ );
+};
+
+// @ts-ignore
+if (module.hot) {
+ const renderAppHot = renderApp;
+ const renderError = (error: Error) => {
+ render(
+ <RedBox error={error}/>,
+ rootEl
+ );
+ };
+
+ renderApp = () => {
+ try {
+ renderAppHot();
+ } catch (error) {
+ renderError(error);
+ }
+ };
+
+ // @ts-ignore
+ module.hot.accept('./app', () => {
+ setTimeout(renderApp);
+ });
+}
+
+renderApp();
+appEl!.appendChild(rootEl);