@@ -24,7 +24,6 @@ export default function withSideEffect (reduceComponentsToState, handleStateChan
24
24
25
25
const mountedInstances = new Set ( )
26
26
let state
27
- let shouldEmitChange = false
28
27
29
28
function emitChange ( component ) {
30
29
state = reduceComponentsToState ( [ ...mountedInstances ] )
@@ -36,12 +35,6 @@ export default function withSideEffect (reduceComponentsToState, handleStateChan
36
35
}
37
36
}
38
37
39
- function maybeEmitChange ( component ) {
40
- if ( ! shouldEmitChange ) return
41
- shouldEmitChange = false
42
- emitChange ( component )
43
- }
44
-
45
38
class SideEffect extends Component {
46
39
// Try to use displayName of wrapped component
47
40
static displayName = `SideEffect(${ getDisplayName ( WrappedComponent ) } )`
@@ -60,8 +53,6 @@ export default function withSideEffect (reduceComponentsToState, handleStateChan
60
53
throw new Error ( 'You may only call rewind() on the server. Call peek() to read the current state.' )
61
54
}
62
55
63
- maybeEmitChange ( )
64
-
65
56
const recordedState = state
66
57
state = undefined
67
58
mountedInstances . clear ( )
@@ -70,24 +61,15 @@ export default function withSideEffect (reduceComponentsToState, handleStateChan
70
61
71
62
componentWillMount ( ) {
72
63
mountedInstances . add ( this )
73
- shouldEmitChange = true
74
- }
75
-
76
- componentDidMount ( ) {
77
- maybeEmitChange ( this )
78
- }
79
-
80
- componentWillUpdate ( ) {
81
- shouldEmitChange = true
64
+ emitChange ( this )
82
65
}
83
66
84
67
componentDidUpdate ( ) {
85
- maybeEmitChange ( this )
68
+ emitChange ( this )
86
69
}
87
70
88
71
componentWillUnmount ( ) {
89
72
mountedInstances . delete ( this )
90
- shouldEmitChange = false
91
73
emitChange ( this )
92
74
}
93
75
0 commit comments