From 21188939b79f959d63f988150dcbadbf1f2379ed Mon Sep 17 00:00:00 2001 From: Garth Poitras Date: Thu, 6 Jul 2017 09:32:36 -0400 Subject: [PATCH] Move ref context binding to fix object freezing middleware (#733) --- src/components/connectAdvanced.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/connectAdvanced.js b/src/components/connectAdvanced.js index 54ffa477c..0c03c6121 100644 --- a/src/components/connectAdvanced.js +++ b/src/components/connectAdvanced.js @@ -121,7 +121,6 @@ export default function connectAdvanced( this.renderCount = 0 this.store = props[storeKey] || context[storeKey] this.propsMode = Boolean(props[storeKey]) - this.setWrappedInstance = this.setWrappedInstance.bind(this) invariant(this.store, `Could not find "${storeKey}" in either the context or props of ` + @@ -240,7 +239,7 @@ export default function connectAdvanced( // instance. a singleton memoized selector would then be holding a reference to the // instance, preventing the instance from being garbage collected, and that would be bad const withExtras = { ...props } - if (withRef) withExtras.ref = this.setWrappedInstance + if (withRef) withExtras.ref = this.setWrappedInstance.bind(this) if (renderCountProp) withExtras[renderCountProp] = this.renderCount++ if (this.propsMode && this.subscription) withExtras[subscriptionKey] = this.subscription return withExtras