From 162e3ec56c8de56d403f3e8524dcabb5e0887257 Mon Sep 17 00:00:00 2001 From: Hazem Krimi Date: Thu, 4 May 2023 18:43:46 +0100 Subject: [PATCH] Fix vite hot reload --- src/index.tsx | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index ccaefc5..c0bdf16 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -65,18 +65,26 @@ export const clientSupport = new ApolloClient({ cache: new InMemoryCache(), }); -ReactDOMClient.createRoot(document.querySelector('#app') as HTMLElement).render( - - - - - - - - - - -); +let root: ReactDOMClient.Root | null = null; + +document.addEventListener('DOMContentLoaded', () => { + if (!root) { + root = ReactDOMClient.createRoot(document.querySelector('#app') as HTMLElement); + + root.render( + + + + + + + + + + + ) + } +}); // If you want to start measuring performance in your app, pass a function // to log results (for example: reportWebVitals(console.log))