Update code to use refs

This commit is contained in:
Shreya 2020-03-10 00:39:35 +05:30
parent e81c044a17
commit 67d88e8ab2
1 changed files with 4 additions and 3 deletions

View File

@ -20,6 +20,7 @@ class MapPageComponent extends AuthComponent {
telemetry: [],
telemetryLastTimestamp: null
};
this.telemConsole = React.createRef();
}
events = {
@ -66,8 +67,8 @@ class MapPageComponent extends AuthComponent {
telemetry: newTelem,
telemetryLastTimestamp: res['timestamp']
});
var telemConsole = document.querySelector('div.telemetry-console');
telemConsole.scrollTop = telemConsole.scrollHeight - telemConsole.clientHeight
var telemConsoleRef = this.telemConsole.current;
telemConsoleRef.scrollTop = telemConsoleRef.scrollHeight - telemConsoleRef.clientHeight
this.props.onStatusChange();
}
});
@ -142,7 +143,7 @@ class MapPageComponent extends AuthComponent {
renderTelemetryConsole() {
return (
<div className="telemetry-console">
<div className="telemetry-console" ref={this.telemConsole}>
{
this.state.telemetry.map(this.renderTelemetryEntry)
}