-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch.diff
More file actions
38 lines (36 loc) · 1.19 KB
/
Copy pathpatch.diff
File metadata and controls
38 lines (36 loc) · 1.19 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
--- src/apps/SystemLogs/SystemLogs.tsx
+++ src/apps/SystemLogs/SystemLogs.tsx
@@ -14,10 +14,18 @@
const LEVEL_FILTER_OPTIONS = ["ALL", "INFO", "SUCCESS", "WARN", "ERROR"];
export const SystemLogs: React.FC = () => {
- const [logs, setLogs] = useState<LogEntry[]>([]);
+ const [logs, setLogs] = useState<LogEntry[]>(() => {
+ const initial: LogEntry[] = [];
+ for (let i = 0; i < 12; i++) {
+ const entry = generateLogEntry();
+ initial.push({ ...entry, id: logId++ });
+ }
+ return initial;
+ });
+
const [filter, setFilter] = useState("ALL");
const [paused, setPaused] = useState(false);
const logEndRef = useRef<HTMLDivElement>(null);
const containerRef = useRef<HTMLDivElement>(null);
useEffect(() => {
if (logEndRef.current && containerRef.current) {
@@ -21,12 +29,4 @@
useEffect(() => {
if (logEndRef.current && containerRef.current) {
containerRef.current.scrollTop = containerRef.current.scrollHeight;
}
}, [logs]);
-
- useEffect(() => {
- const initial: LogEntry[] = [];
- for (let i = 0; i < 12; i++) {
- const entry = generateLogEntry();
- initial.push({ ...entry, id: logId++ });
- }
- setLogs(initial);
- }, []);