RelatedResources retrieve link.title directly
authorPhilippe Pepiot <philippe.pepiot@logilab.fr>
Tue, 30 May 2017 16:31:37 +0200
changeset 218 b1eb36b816da
parent 217 67419e09a231
child 219 b53a022e0c51
RelatedResources retrieve link.title directly Since only title attribute is actually used. This make the component more reusable.
src/components/Entity.js
src/components/Resource.js
--- a/src/components/Entity.js	Tue May 30 16:24:33 2017 +0200
+++ b/src/components/Entity.js	Tue May 30 16:31:37 2017 +0200
@@ -82,7 +82,7 @@
     function renderTitle() {
         return (
             <div>
-                { props.link.title }
+                { props.title }
                 { renderActions() }
                 <div className="clearfix" />
             </div>
@@ -120,7 +120,7 @@
 }
 
 RelatedResources.propTypes = {
-    link: PropTypes.object.isRequired,
+    title: PropTypes.string.isRequired,
     resource: PropTypesResourceModel.isRequired,
 };
 
--- a/src/components/Resource.js	Tue May 30 16:24:33 2017 +0200
+++ b/src/components/Resource.js	Tue May 30 16:31:37 2017 +0200
@@ -132,7 +132,7 @@
         const links = entity.links('related');
         if (links.length > 0) {
             return Array.prototype.map.call(links, (link) => {
-                return <ResourceContainer url={link.href} component={RelatedResources} childProps={{link: link}} key={link.title} />;
+                return <ResourceContainer url={link.href} component={RelatedResources} childProps={{title: link.title}} key={link.title} />;
             });
         }
         return null;