From 9ec6ee52999fb47ab02b414759155bb2d3414831 Mon Sep 17 00:00:00 2001 From: Aaron Contreras Date: Sun, 23 Apr 2017 16:16:06 +0200 Subject: [PATCH] Do not create new functions in render. Fix #66 --- src/components/connect-request.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/components/connect-request.js b/src/components/connect-request.js index 1a72ac93..d3479f2f 100644 --- a/src/components/connect-request.js +++ b/src/components/connect-request.js @@ -1,4 +1,3 @@ -import partial from 'lodash.partial'; import difference from 'lodash.difference'; import includes from 'lodash.includes'; import intersection from 'lodash.intersection'; @@ -31,6 +30,8 @@ const connectRequest = (mapPropsToConfigs, options = {}) => WrappedComponent => constructor() { super(); + this.forceRequest = this.forceRequest.bind(this); + // A set of URLs that identify all pending requests this._pendingRequests = {}; this._wrappedInstance = null; @@ -115,22 +116,23 @@ const connectRequest = (mapPropsToConfigs, options = {}) => WrappedComponent => } } - render() { - const configs = mapPropsToConfigs(this.props); - const forceRequest = partial(this.requestAsync.bind(this), configs, true, false); + forceRequest() { + this.requestAsync(mapPropsToConfigs(this.props), true, false); + } + render() { if (withRef) { return ( { this._wrappedInstance = ref; }} /> ); } else { - return ; + return ; } } }