@@ -288,27 +288,24 @@ class ShallowWrapper {
288288 if (
289289 shouldRender &&
290290 ! this [ OPTIONS ] . disableLifecycleMethods &&
291- instance &&
292- typeof instance . componentDidUpdate === 'function'
291+ instance
293292 ) {
293+ // getSnapshotBeforeUpdate
294+ let snapshot ;
294295 if (
295- ! this [ OPTIONS ] . disableLifecycleMethods &&
296- instance
296+ adapter . options . supportGetSnapshotBeforeUpdate
297+ && typeof instance . getSnapshotBeforeUpdate === 'function'
297298 ) {
298- if (
299- adapter . options . supportGetSnapshotBeforeUpdate
300- && typeof instance . getSnapshotBeforeUpdate === 'function'
301- ) {
302- const snapshot = instance . getSnapshotBeforeUpdate ( prevProps , state ) ;
303- if ( typeof instance . componentDidUpdate === 'function' ) {
304- instance . componentDidUpdate ( prevProps , state , snapshot ) ;
305- }
306- } else if ( typeof instance . componentDidUpdate === 'function' ) {
307- if ( adapter . options . supportPrevContextArgumentOfComponentDidUpdate ) {
308- instance . componentDidUpdate ( prevProps , state , prevContext ) ;
309- } else {
310- instance . componentDidUpdate ( prevProps , state ) ;
311- }
299+ snapshot = instance . getSnapshotBeforeUpdate ( prevProps , state ) ;
300+ }
301+ // componentDidUpdate
302+ if ( typeof instance . componentDidUpdate === 'function' ) {
303+ if ( adapter . options . supportGetSnapshotBeforeUpdate ) {
304+ instance . componentDidUpdate ( prevProps , state , snapshot ) ;
305+ } else if ( adapter . options . supportPrevContextArgumentOfComponentDidUpdate ) {
306+ instance . componentDidUpdate ( prevProps , state , prevContext ) ;
307+ } else {
308+ instance . componentDidUpdate ( prevProps , state ) ;
312309 }
313310 }
314311 // If it doesn't need to rerender, update only its props.
0 commit comments