Fall-back to image name as key when there is no id

When a container is first started and the image is downloading there is
no id set. With this patch we'll check if the container has a id and
and is downloading, if so we'll substitute it with the image name and
render such.

This will fix the react key props warning in the developer console as
well as maybe give us some sort of performance boost(?)

Signed-off-by: Kristján Oddsson <koddsson@gmail.com>
This commit is contained in:
Kristján Oddsson 2015-04-05 17:01:18 +00:00
parent b67c1a912e
commit dfe80af6e4
1 changed files with 7 additions and 1 deletions

View File

@ -9,8 +9,14 @@ var ContainerList = React.createClass({
render: function () {
var self = this;
var containers = this.props.containers.map(function (container) {
var container_id = container.Id;
if (!container_id && container.State.Downloading) {
// Fall back to the container image name when there is no id. (when the
// image is downloading).
container_id = container.Image;
}
return (
<ContainerListItem key={container.Id} container={container} start={self._start}/>
<ContainerListItem key={container_id} container={container} start={self._start} />
);
});
var newItem;