@@ -7,6 +7,8 @@ let generation = 1;
7
7
// these counters are aimed to mitigate the "first render"
8
8
let hotComparisonCounter = 0 ;
9
9
let hotComparisonRuns = 0 ;
10
+ let hotReplacementGeneration = 0 ;
11
+
10
12
const nullFunction = ( ) => ( { } ) ;
11
13
12
14
// these callbacks would be called on component update
@@ -24,7 +26,8 @@ export const setComparisonHooks = (open, element, close) => {
24
26
export const getElementComparisonHook = component => onHotComparisonElement ( component ) ;
25
27
export const getElementCloseHook = component => onHotComparisonClose ( component ) ;
26
28
27
- export const hotComparisonOpen = ( ) => hotComparisonCounter > 0 && hotComparisonRuns > 0 ;
29
+ export const hotComparisonOpen = ( ) =>
30
+ hotComparisonCounter > 0 && hotComparisonRuns > 0 && hotReplacementGeneration > 0 ;
28
31
29
32
const openGeneration = ( ) => forEachKnownClass ( onHotComparisonElement ) ;
30
33
@@ -48,6 +51,7 @@ const decrementHot = () => {
48
51
export const configureGeneration = ( counter , runs ) => {
49
52
hotComparisonCounter = counter ;
50
53
hotComparisonRuns = runs ;
54
+ hotReplacementGeneration = runs ;
51
55
} ;
52
56
53
57
// TODO: shall it be called from incrementHotGeneration?
@@ -63,6 +67,5 @@ export const increment = () => {
63
67
export const get = ( ) => generation ;
64
68
65
69
// These counters tracks HMR generations, and probably should be used instead of the old one
66
- let hotReplacementGeneration = 0 ;
67
70
export const incrementHotGeneration = ( ) => hotReplacementGeneration ++ ;
68
71
export const getHotGeneration = ( ) => hotReplacementGeneration ;
0 commit comments