Skip to content

Commit

Permalink
remove jQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-20 committed Mar 23, 2024
1 parent bb601f2 commit 7200c77
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions workspaces/client/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// import './side-effects';

import $ from 'jquery';
import ReactDOM from 'react-dom/client';
import { BrowserRouter } from 'react-router-dom';
import { SWRConfig } from 'swr';
Expand All @@ -15,13 +14,18 @@ const main = async () => {
await registerServiceWorker();
// await preloadImages();

$(document).ready(() => {
document.addEventListener('load', () => {
const rootElement = document.getElementById('root');
if (!rootElement) {
throw new Error('Root element not found');
}

if (window.location.pathname.startsWith('/admin')) {
ReactDOM.createRoot($('#root').get(0)!).render(<AdminApp />);
ReactDOM.createRoot(rootElement!).render(<AdminApp />);
} else {
ReactDOM.hydrateRoot(
$('#root').get(0)!,
<SWRConfig value={{ revalidateIfStale: true, revalidateOnFocus: false, revalidateOnReconnect: false }}>
rootElement!,
<SWRConfig value={{ revalidateOnFocus: false, revalidateOnReconnect: false }}>
<BrowserRouter>
<ClientApp />
</BrowserRouter>
Expand Down

0 comments on commit 7200c77

Please sign in to comment.