Skip to content

Commit 2118893

Browse files
Garth Poitrastimdorr
authored andcommitted
Move ref context binding to fix object freezing middleware (#733)
1 parent 2726c59 commit 2118893

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/components/connectAdvanced.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ export default function connectAdvanced(
121121
this.renderCount = 0
122122
this.store = props[storeKey] || context[storeKey]
123123
this.propsMode = Boolean(props[storeKey])
124-
this.setWrappedInstance = this.setWrappedInstance.bind(this)
125124

126125
invariant(this.store,
127126
`Could not find "${storeKey}" in either the context or props of ` +
@@ -240,7 +239,7 @@ export default function connectAdvanced(
240239
// instance. a singleton memoized selector would then be holding a reference to the
241240
// instance, preventing the instance from being garbage collected, and that would be bad
242241
const withExtras = { ...props }
243-
if (withRef) withExtras.ref = this.setWrappedInstance
242+
if (withRef) withExtras.ref = this.setWrappedInstance.bind(this)
244243
if (renderCountProp) withExtras[renderCountProp] = this.renderCount++
245244
if (this.propsMode && this.subscription) withExtras[subscriptionKey] = this.subscription
246245
return withExtras

0 commit comments

Comments
 (0)