Add braces and simplify/improve oldLength handling
@@ -75,14 +75,15 @@ export class LogConsole extends Component {
componentWillReceiveProps(nextProps) {
// eslint-disable-line
logger.debug('newProps isArray', Array.isArray(nextProps.logArray));
- if (nextProps.logArray === undefined)
+ if (nextProps.logArray === undefined) {
return;
+ }
// We need a shallow copy of the ObservableArray to "cast" it down to normal array
const newArray = nextProps.logArray.slice();
- const oldArray = this.props.logArray !== undefined && this.props.logArray.slice();
+ const oldLength = this.props.logArray && this.props.logArray.length || 0;
// if have a new logArray, simply add it to the queue and wait for next tick
- this.queuedLines = this.queuedLines.concat(newArray.slice(oldArray.length));
+ this.queuedLines = this.queuedLines.concat(newArray.slice(oldLength));
clearTimeout(this.timeouts.render);
this.timeouts.render = setTimeout(() => {
this._processNextLines();
