-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.tsx
More file actions
44 lines (36 loc) · 1.21 KB
/
Copy pathindex.tsx
File metadata and controls
44 lines (36 loc) · 1.21 KB
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
40
41
42
43
44
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
import './index.css';
import { initializeFirebase, initializeAuth, loadFirebaseConfig } from './lib/firebase';
import { defaultConfig } from './lib/firebaseConfig';
// --- Global Firebase Initialization ---
// This ensures Firebase is initialized once before any component renders.
const initializeAppOnLoad = () => {
const useDemo = localStorage.getItem('useDemoData') === 'true';
if (useDemo) {
console.log("Running in Demo Mode. Firebase will not be initialized.");
return;
}
const loadedConfig = loadFirebaseConfig();
const configToUse = loadedConfig || defaultConfig;
if (configToUse && configToUse.apiKey) {
if (initializeFirebase(configToUse)) {
initializeAuth(configToUse);
}
} else {
console.warn("No valid Firebase config found. App will run without Firebase connection.");
}
};
initializeAppOnLoad();
// --- End of Initialization ---
const rootElement = document.getElementById('root');
if (!rootElement) {
throw new Error("Could not find root element to mount to");
}
const root = ReactDOM.createRoot(rootElement);
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);