Check collection length using length method instead of isEmpty
authorFrank Bessou <frank.bessou@logilab.fr>
Wed, 03 May 2017 11:01:27 +0200
changeset 173 965aeaedcde3
parent 172 71a41a02d5ce
child 174 de0bc05b4792
Check collection length using length method instead of isEmpty The isEmpty function was not appropriate as the props.entities is not an array. We have to use the length() method of props.entities.data which is a jsonary wrapper instead.
src/components/Entities.js
--- a/src/components/Entities.js	Wed May 03 11:23:26 2017 +0200
+++ b/src/components/Entities.js	Wed May 03 11:01:27 2017 +0200
@@ -1,6 +1,5 @@
 import React from 'react';
 import {PropTypes} from 'prop-types';
-import {isEmpty} from 'lodash/lang';
 import {ActionsDropDown, CollectionView} from './BaseViews';
 import Api from '../Api';
 import {PropTypesEntitiesModel} from '../model';
@@ -45,7 +44,7 @@
     }
 
     function renderEntities() {
-        if (!isEmpty(props.entities)) {
+        if (props.entities.data.length() > 0) {
             return <CollectionView collection={props.entities} />;
         }