@@ -2,13 +2,19 @@ import React from 'react';
2
2
import ReactDOM from 'react-dom/client' ;
3
3
import App from './App' ;
4
4
import { Provider } from 'react-redux' ;
5
- // import reportWebVitals from './reportWebVitals';
6
5
import { store } from './store' ;
7
6
8
- const initialURL = window . location . href ;
9
- if ( initialURL . includes ( '/#/' ) ) {
10
- window . location . href = initialURL . replace ( '/#/' , '/' ) ;
11
- } else {
7
+ // Handle redirection for hash-based URLs
8
+ const handleURLRedirection = ( ) => {
9
+ const initialURL = window . location . href ;
10
+ if ( initialURL . includes ( '/#/' ) ) {
11
+ window . location . href = initialURL . replace ( '/#/' , '/' ) ;
12
+ return true ;
13
+ }
14
+ return false ;
15
+ } ;
16
+
17
+ const initializeApp = ( ) => {
12
18
const root = ReactDOM . createRoot ( document . getElementById ( 'root' ) as HTMLElement ) ;
13
19
root . render (
14
20
< React . StrictMode >
@@ -17,9 +23,14 @@ if (initialURL.includes('/#/')) {
17
23
</ Provider >
18
24
</ React . StrictMode > ,
19
25
) ;
26
+ } ;
20
27
21
- // If you want to start measuring performance in your app, pass a function
22
- // to log results (for example: reportWebVitals(console.log))
23
- // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
24
- // reportWebVitals();
28
+ if ( ! handleURLRedirection ( ) ) {
29
+ // Initialize the app only if redirection is not needed
30
+ initializeApp ( ) ;
25
31
}
32
+
33
+ // If you want to start measuring performance in your app, pass a function
34
+ // to log results (for example: reportWebVitals(console.log))
35
+ // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
36
+ // reportWebVitals();
0 commit comments