-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug-react.html
More file actions
166 lines (144 loc) · 6.8 KB
/
debug-react.html
File metadata and controls
166 lines (144 loc) · 6.8 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>React Debug Test</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
.debug-panel { background: #f0f0f0; padding: 20px; border-radius: 8px; margin: 20px 0; }
.error { color: red; }
.success { color: green; }
.info { color: blue; }
#console-output { background: #000; color: #0f0; padding: 10px; border-radius: 4px; font-family: monospace; height: 300px; overflow-y: auto; }
</style>
</head>
<body>
<h1>React Debug Test</h1>
<div class="debug-panel">
<h3>Test Controls</h3>
<button onclick="testReactApp()">Test React App</button>
<button onclick="clearConsole()">Clear Console</button>
<button onclick="checkPageContent()">Check Page Content</button>
</div>
<div class="debug-panel">
<h3>Console Output</h3>
<div id="console-output"></div>
</div>
<div class="debug-panel">
<h3>Page Analysis</h3>
<div id="page-analysis"></div>
</div>
<script>
// Override console methods to capture output
const originalLog = console.log;
const originalError = console.error;
const originalWarn = console.warn;
function addToConsole(type, message, ...args) {
const consoleOutput = document.getElementById('console-output');
const timestamp = new Date().toLocaleTimeString();
const logEntry = document.createElement('div');
logEntry.className = type;
logEntry.innerHTML = `[${timestamp}] ${type.toUpperCase()}: ${message} ${args.map(arg =>
typeof arg === 'object' ? JSON.stringify(arg, null, 2) : String(arg)
).join(' ')}`;
consoleOutput.appendChild(logEntry);
consoleOutput.scrollTop = consoleOutput.scrollHeight;
}
console.log = function(message, ...args) {
originalLog.apply(console, [message, ...args]);
addToConsole('info', message, ...args);
};
console.error = function(message, ...args) {
originalError.apply(console, [message, ...args]);
addToConsole('error', message, ...args);
};
console.warn = function(message, ...args) {
originalWarn.apply(console, [message, ...args]);
addToConsole('warn', message, ...args);
};
function clearConsole() {
document.getElementById('console-output').innerHTML = '';
}
function checkPageContent() {
const analysis = document.getElementById('page-analysis');
analysis.innerHTML = '';
// Check if React app is running
const rootElement = document.getElementById('root');
if (rootElement) {
addToConsole('info', 'Root element found:', rootElement);
addToConsole('info', 'Root element innerHTML length:', rootElement.innerHTML.length);
addToConsole('info', 'Root element children count:', rootElement.children.length);
if (rootElement.innerHTML.length > 0) {
addToConsole('success', 'React app appears to be running');
analysis.innerHTML += '<p class="success">✅ React app is running</p>';
} else {
addToConsole('warn', 'Root element is empty - React app may not be running');
analysis.innerHTML += '<p class="error">❌ Root element is empty</p>';
}
} else {
addToConsole('error', 'Root element not found');
analysis.innerHTML += '<p class="error">❌ Root element not found</p>';
}
// Check for React-specific elements
const reactElements = document.querySelectorAll('[data-reactroot], [data-reactid]');
if (reactElements.length > 0) {
addToConsole('success', 'React elements found:', reactElements.length);
analysis.innerHTML += '<p class="success">✅ React elements detected</p>';
} else {
addToConsole('warn', 'No React elements found');
analysis.innerHTML += '<p class="warn">⚠️ No React elements detected</p>';
}
// Check for map container
const mapContainer = document.querySelector('.mapboxgl-map, [class*="map"], [id*="map"]');
if (mapContainer) {
addToConsole('success', 'Map container found:', mapContainer);
analysis.innerHTML += '<p class="success">✅ Map container found</p>';
} else {
addToConsole('warn', 'No map container found');
analysis.innerHTML += '<p class="warn">⚠️ No map container found</p>';
}
}
function testReactApp() {
addToConsole('info', 'Testing React app...');
// Check if React is available globally
if (window.React) {
addToConsole('success', 'React is available globally');
} else {
addToConsole('warn', 'React is not available globally');
}
if (window.ReactDOM) {
addToConsole('success', 'ReactDOM is available globally');
} else {
addToConsole('warn', 'ReactDOM is not available globally');
}
// Check for any errors in the page
const errors = document.querySelectorAll('.error, [class*="error"], [id*="error"]');
if (errors.length > 0) {
addToConsole('warn', 'Error elements found:', errors.length);
errors.forEach((error, index) => {
if (index < 5) { // Limit to first 5 errors
addToConsole('error', 'Error element:', error.textContent);
}
});
}
// Check page content
checkPageContent();
}
// Auto-run some checks when page loads
window.addEventListener('load', function() {
addToConsole('info', 'Page loaded, running initial checks...');
setTimeout(() => {
testReactApp();
}, 1000);
});
// Monitor for errors
window.addEventListener('error', function(event) {
addToConsole('error', 'Global error:', event.error);
});
window.addEventListener('unhandledrejection', function(event) {
addToConsole('error', 'Unhandled promise rejection:', event.reason);
});
</script>
</body>
</html>