-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
main.tsx
39 lines (36 loc) · 1011 Bytes
/
main.tsx
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/client';
import { RouterProvider, createBrowserRouter } from 'react-router-dom';
import { HelmetProvider } from 'react-helmet-async';
import Index from './pages';
import NotFound from './pages/404';
import ReactGA from 'react-ga4';
import {
GOOGLE_ANALYTICS_TRACKING_ID,
USE_GOOGLE_ANALYTICS,
} from './utils/const';
import '@/styles/index.css';
import { withOptionalGAPageTracking } from './utils/trackRoute';
if (USE_GOOGLE_ANALYTICS) {
ReactGA.initialize(GOOGLE_ANALYTICS_TRACKING_ID);
}
const routes = createBrowserRouter(
[
{
path: '/',
element: withOptionalGAPageTracking(<Index />),
},
{
path: '*',
element: withOptionalGAPageTracking(<NotFound />),
},
],
{ basename: import.meta.env.BASE_URL }
);
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<HelmetProvider>
<RouterProvider router={routes} />
</HelmetProvider>
</React.StrictMode>
);