Initialize props with immutable map/list

This commit is contained in:
Roland Schilter
2017-06-29 17:25:01 +02:00
parent 6b414ee435
commit c812df88c3

View File

@@ -1,4 +1,5 @@
import React from 'react';
import { Map as makeMap, List as makeList } from 'immutable';
import ShowMore from '../show-more';
import NodeDetailsHealthOverflow from './node-details-health-overflow';
@@ -21,8 +22,13 @@ export default class NodeDetailsHealth extends React.Component {
}
render() {
const { metrics = [], metricLinks = {}, topologyId } = this.props;
const unattachedLinks = this.props.unattachedLinks || {};
const {
metrics = makeList(),
metricLinks = makeMap(),
unattachedLinks = makeMap(),
topologyId,
} = this.props;
const hasUnattached = Object.keys(unattachedLinks).length > 0;
const primeCutoff = metrics.length > 3 && !this.state.expanded ? 2 : metrics.length;
const primeMetrics = metrics.slice(0, primeCutoff);