@@ -244,10 +244,11 @@ describe('ReactCompositeComponent', () => {
244
244
ReactDOM . unmountComponentAtNode ( container ) ;
245
245
246
246
expect ( ( ) => instance . forceUpdate ( ) ) . toWarnDev (
247
- 'Can only update a mounted or mounting component. This usually means ' +
248
- 'you called setState, replaceState, or forceUpdate on an unmounted ' +
249
- 'component. This is a no-op.\n\nPlease check the code for the ' +
250
- 'Component component.' ,
247
+ "Warning: Can't call setState (or forceUpdate) on an unmounted " +
248
+ 'component. This is a no-op, but it indicates a memory leak in your ' +
249
+ 'application. To fix, cancel all subscriptions and asynchronous ' +
250
+ 'tasks in the componentWillUnmount method.\n' +
251
+ ' in Component (at **)' ,
251
252
) ;
252
253
253
254
// No additional warning should be recorded
@@ -269,26 +270,33 @@ describe('ReactCompositeComponent', () => {
269
270
}
270
271
}
271
272
272
- let instance = < Component /> ;
273
- expect ( instance . setState ) . not . toBeDefined ( ) ;
274
-
275
- instance = ReactDOM . render ( instance , container ) ;
273
+ let instance ;
274
+ ReactDOM . render (
275
+ < div >
276
+ < span >
277
+ < Component ref = { c => ( instance = c || instance ) } />
278
+ </ span >
279
+ </ div > ,
280
+ container ,
281
+ ) ;
276
282
277
283
expect ( renders ) . toBe ( 1 ) ;
278
284
279
285
instance . setState ( { value : 1 } ) ;
280
286
281
287
expect ( renders ) . toBe ( 2 ) ;
282
288
283
- ReactDOM . unmountComponentAtNode ( container ) ;
289
+ ReactDOM . render ( < div /> , container ) ;
284
290
285
291
expect ( ( ) => {
286
292
instance . setState ( { value : 2 } ) ;
287
293
} ) . toWarnDev (
288
- 'Can only update a mounted or mounting component. This usually means ' +
289
- 'you called setState, replaceState, or forceUpdate on an unmounted ' +
290
- 'component. This is a no-op.\n\nPlease check the code for the ' +
291
- 'Component component.' ,
294
+ "Warning: Can't call setState (or forceUpdate) on an unmounted " +
295
+ 'component. This is a no-op, but it indicates a memory leak in your ' +
296
+ 'application. To fix, cancel all subscriptions and asynchronous ' +
297
+ 'tasks in the componentWillUnmount method.\n' +
298
+ ' in Component (at **)\n' +
299
+ ' in span' ,
292
300
) ;
293
301
294
302
expect ( renders ) . toBe ( 2 ) ;
0 commit comments