@@ -108,6 +108,7 @@ export default function createConnect(React) {
108
108
super ( props , context ) ;
109
109
this . version = version ;
110
110
this . store = props . store || context . store ;
111
+ this . mapStateMemoize = null ;
111
112
112
113
invariant ( this . store ,
113
114
`Could not find "store" in either the context or ` +
@@ -157,6 +158,9 @@ export default function createConnect(React) {
157
158
this . updateDispatchProps ( nextProps ) ;
158
159
}
159
160
161
+ if ( shouldUpdateStateProps ) {
162
+ this . mapStateMemoize = null ;
163
+ }
160
164
}
161
165
}
162
166
@@ -169,7 +173,12 @@ export default function createConnect(React) {
169
173
return ;
170
174
}
171
175
172
- this . setState ( { storeState : this . store . getState ( ) } ) ;
176
+ const storeState = this . store . getState ( ) ;
177
+ if ( storeState !== this . state . storeState ) {
178
+ this . mapStateMemoize = null ;
179
+ }
180
+
181
+ this . setState ( { storeState} ) ;
173
182
}
174
183
175
184
getWrappedInstance ( ) {
@@ -181,8 +190,12 @@ export default function createConnect(React) {
181
190
}
182
191
183
192
computeNextState ( ) {
193
+ if ( this . mapStateMemoize === null ) {
194
+ this . mapStateMemoize = computeStateProps ( this . state . storeState , this . props ) ;
195
+ }
196
+
184
197
return computeNextState (
185
- computeStateProps ( this . state . storeState , this . props ) ,
198
+ this . mapStateMemoize ,
186
199
this . state . dispatchProps ,
187
200
this . props
188
201
) ;
@@ -214,6 +227,8 @@ export default function createConnect(React) {
214
227
// We are hot reloading!
215
228
this . version = version ;
216
229
230
+ this . mapStateMemoize = null ;
231
+
217
232
// Update the state and bindings.
218
233
this . trySubscribe ( ) ;
219
234
this . updateDispatchProps ( ) ;
0 commit comments