RelatedResources: drop renderActions()
authorPhilippe Pepiot <philippe.pepiot@logilab.fr>
Tue, 30 May 2017 17:37:41 +0200
changeset 221 714b33df76bb
parent 220 44873bd54b07
child 222 46b85a896c43
RelatedResources: drop renderActions() Since the function is called only once, use a variable instead.
src/components/Entity.js
--- a/src/components/Entity.js	Tue May 30 16:39:11 2017 +0200
+++ b/src/components/Entity.js	Tue May 30 17:37:41 2017 +0200
@@ -70,13 +70,9 @@
 };
 
 export function RelatedResources(props) {
-    function renderActions() {
-        const related = props.resource;
-        if (!related || related.allowedActions.length <= 1) {
-            return null;
-        }
-        return <ActionsDropDown target={related} ignore={['view']} />;
-
+    let actions = null;
+    if (props.resource !== null && props.resource.allowedActions.length > 1) {
+        actions = <ActionsDropDown target={props.resource} ignore={['view']} />;
     }
 
     let related = null;
@@ -93,7 +89,7 @@
             <div className="panel-heading">
                 <div className="panel-title">
                     { props.title }
-                    { renderActions() }
+                    { actions }
                     <div className="clearfix" />
                 </div>
             </div>