Update code to use refs
This commit is contained in:
parent
e81c044a17
commit
67d88e8ab2
|
@ -20,6 +20,7 @@ class MapPageComponent extends AuthComponent {
|
||||||
telemetry: [],
|
telemetry: [],
|
||||||
telemetryLastTimestamp: null
|
telemetryLastTimestamp: null
|
||||||
};
|
};
|
||||||
|
this.telemConsole = React.createRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
events = {
|
events = {
|
||||||
|
@ -66,8 +67,8 @@ class MapPageComponent extends AuthComponent {
|
||||||
telemetry: newTelem,
|
telemetry: newTelem,
|
||||||
telemetryLastTimestamp: res['timestamp']
|
telemetryLastTimestamp: res['timestamp']
|
||||||
});
|
});
|
||||||
var telemConsole = document.querySelector('div.telemetry-console');
|
var telemConsoleRef = this.telemConsole.current;
|
||||||
telemConsole.scrollTop = telemConsole.scrollHeight - telemConsole.clientHeight
|
telemConsoleRef.scrollTop = telemConsoleRef.scrollHeight - telemConsoleRef.clientHeight
|
||||||
this.props.onStatusChange();
|
this.props.onStatusChange();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -142,7 +143,7 @@ class MapPageComponent extends AuthComponent {
|
||||||
|
|
||||||
renderTelemetryConsole() {
|
renderTelemetryConsole() {
|
||||||
return (
|
return (
|
||||||
<div className="telemetry-console">
|
<div className="telemetry-console" ref={this.telemConsole}>
|
||||||
{
|
{
|
||||||
this.state.telemetry.map(this.renderTelemetryEntry)
|
this.state.telemetry.map(this.renderTelemetryEntry)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue