Skip to content

Commit

Permalink
Interleave the snapshot variable
Browse files Browse the repository at this point in the history
  • Loading branch information
koba04 committed Jul 4, 2018
1 parent f92e09d commit b508490
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions packages/enzyme/src/ShallowWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,22 +339,20 @@ class ShallowWrapper {
instance
) {
const lifecycles = getAdapterLifecycles(adapter);
// getSnapshotBeforeUpdate
let snapshot;
if (
lifecycles.getSnapshotBeforeUpdate
&& typeof instance.getSnapshotBeforeUpdate === 'function'
) {
snapshot = instance.getSnapshotBeforeUpdate(prevProps, state);
}
// componentDidUpdate
if (

if (lifecycles.getSnapshotBeforeUpdate) {
let snapshot;
if (typeof instance.getSnapshotBeforeUpdate === 'function') {
snapshot = instance.getSnapshotBeforeUpdate(prevProps, state);
}
if (typeof instance.componentDidUpdate === 'function') {
instance.componentDidUpdate(prevProps, state, snapshot);
}
} else if (
lifecycles.componentDidUpdate &&
typeof instance.componentDidUpdate === 'function'
) {
if (lifecycles.getSnapshotBeforeUpdate) {
instance.componentDidUpdate(prevProps, state, snapshot);
} else if (lifecycles.componentDidUpdate.prevContext) {
if (lifecycles.componentDidUpdate.prevContext) {
instance.componentDidUpdate(prevProps, state, prevContext);
} else {
instance.componentDidUpdate(prevProps, state);
Expand Down

0 comments on commit b508490

Please sign in to comment.