RelatedResources: drop renderRelated()
authorPhilippe Pepiot <philippe.pepiot@logilab.fr>
Tue, 30 May 2017 16:39:11 +0200
changeset 220 44873bd54b07
parent 219 b53a022e0c51
child 221 714b33df76bb
RelatedResources: drop renderRelated() Since the function is called only once, use a variable instead.
src/components/Entity.js
--- a/src/components/Entity.js	Tue May 30 16:34:30 2017 +0200
+++ b/src/components/Entity.js	Tue May 30 16:39:11 2017 +0200
@@ -79,22 +79,13 @@
 
     }
 
-    function renderRelated() {
-        if (props.resource === null) {
-            return (
-                    <div className="panel-body text-muted">
-                        loading...
-                    </div>
-            );
-        } else if (props.resource.data.length() === 0) {
-            return (
-                    <div className="panel-body text-muted">
-                        nothing related yet
-                    </div>
-            );
-        } else {
-            return <CollectionView collection={props.resource.data} />;
-        }
+    let related = null;
+    if (props.resource === null) {
+        related = <div className="panel-body text-muted">loading...</div>;
+    } else if (props.resource.data.length() === 0) {
+        related = <div className="panel-body text-muted">nothing related yet</div>;
+    } else {
+        related = <CollectionView collection={props.resource.data} />;
     }
 
     return (
@@ -106,7 +97,7 @@
                     <div className="clearfix" />
                 </div>
             </div>
-            { renderRelated() }
+            { related }
         </div>
     );
 }