Skip to content

Commit 1440fd0

Browse files
authored
logRef scrollable
1 parent a1accf7 commit 1440fd0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/TrainSimulator.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ function TrainSimulator() {
1515
const logElement = document.createElement('div');
1616
logElement.innerText = JSON.stringify({ speed, throttle, pressure });
1717
logRef.current.appendChild(logElement);
18-
logRef.scrollTop = logRef.scrollHeight;
18+
if (logRef.current) {
19+
logRef.current.scrollTop = logRef.current.scrollHeight;
20+
}
1921

2022
}, 1000);
2123
} else {
2224
clearInterval(intervalRef.current);
2325
}
2426

25-
27+
2628

2729

2830
return () => {

0 commit comments

Comments
 (0)