From 4065a65fe3294e0ddf54f5756380f7dc1aa032b2 Mon Sep 17 00:00:00 2001 From: Maksymilian Pamula Date: Wed, 22 Apr 2020 06:46:36 +0200 Subject: TD: Rewrite application to TS --- core/search-component/src/main/components/root.tsx | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 core/search-component/src/main/components/root.tsx (limited to 'core/search-component/src/main/components/root.tsx') 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( + , + rootEl + ); +}; + +// @ts-ignore +if (module.hot) { + const renderAppHot = renderApp; + const renderError = (error: Error) => { + render( + , + rootEl + ); + }; + + renderApp = () => { + try { + renderAppHot(); + } catch (error) { + renderError(error); + } + }; + + // @ts-ignore + module.hot.accept('./app', () => { + setTimeout(renderApp); + }); +} + +renderApp(); +appEl!.appendChild(rootEl); -- cgit