Make ResourceContainer usable with withPagination
authorPhilippe Pepiot <philippe.pepiot@logilab.fr>
Wed, 07 Jun 2017 14:07:02 +0200
changeset 225 79e8794592ec
parent 224 13f568434dcd
child 226 1e18e08035d3
Make ResourceContainer usable with withPagination By providing changeRoute and className props that are required.
src/components/Resource.js
--- a/src/components/Resource.js	Tue Jun 06 16:50:39 2017 +0200
+++ b/src/components/Resource.js	Wed Jun 07 14:07:02 2017 +0200
@@ -16,6 +16,7 @@
         this.state = this.getInitialState();
         this.hypermediaClient = hypermediaClient;
         this.updateResource = this.updateResource.bind(this);
+        this.initResource = this.initResource.bind(this);
     }
 
     getInitialState() {
@@ -59,7 +60,8 @@
         }
         const Component = this.props.component;
         const childProps = this.props.childProps || {};
-        return <Component {...childProps} updateResource={this.updateResource} resource={this.state.resource} />;
+        return <Component {...childProps} changeRoute={this.initResource}
+            updateResource={this.updateResource} resource={this.state.resource} />;
     }
 
 }