Commit 62bc67e 1 parent 7500b0e commit 62bc67e Copy full SHA for 62bc67e
File tree 2 files changed +28
-1
lines changed
2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import ReactDOM from 'react-dom';
4
4
import hydrateFiberStack from './stack/hydrateFiberStack' ;
5
5
import hydrateLegacyStack from './stack/hydrateLegacyStack' ;
6
6
import { getInternalInstance } from './reactUtils' ;
7
+ import { resolveType } from '../reconciler/resolver' ;
7
8
8
9
function getReactStack ( instance ) {
9
10
const rootNode = getInternalInstance ( instance ) ;
@@ -30,10 +31,18 @@ const markUpdate = ({ fiber }) => {
30
31
if ( ! fiber || typeof fiber . type === 'string' ) {
31
32
return ;
32
33
}
34
+
35
+ const mostResentType = resolveType ( fiber . type ) || fiber . type ;
36
+ if ( fiber . elementType === fiber . type ) {
37
+ fiber . elementType = mostResentType ;
38
+ }
39
+ fiber . type = mostResentType ;
40
+
33
41
fiber . expirationTime = 1 ;
34
42
if ( fiber . alternate ) {
35
43
fiber . alternate . expirationTime = 1 ;
36
44
fiber . alternate . type = fiber . type ;
45
+ fiber . alternate . elementType = fiber . elementType ;
37
46
}
38
47
39
48
if ( fiber . memoizedProps && typeof fiber . memoizedProps === 'object' ) {
Original file line number Diff line number Diff line change @@ -66,12 +66,30 @@ export function resolveNotComponent(type) {
66
66
return undefined ;
67
67
}
68
68
69
+ export const getLatestTypeVersion = type => {
70
+ const existingProxy = getProxyByType ( type ) ;
71
+ return existingProxy && existingProxy . getCurrent && existingProxy . getCurrent ( ) ;
72
+ } ;
73
+
69
74
export const resolveSimpleType = type => {
70
75
if ( ! type ) {
71
76
return type ;
72
77
}
73
78
74
- return resolveProxy ( type ) || resolveUtility ( type ) || type ;
79
+ const simpleResult = resolveProxy ( type ) || resolveUtility ( type ) || resolveNotComponent ( type ) ;
80
+ if ( simpleResult ) {
81
+ return simpleResult ;
82
+ }
83
+
84
+ const lastType = getLatestTypeVersion ( type ) ;
85
+
86
+ // only lazy loaded components any now failing into this branch
87
+
88
+ // if (lastType && lastType !== type) {
89
+ // console.warn('RHL: used type', type, 'is obsolete. Something is wrong with HMR.');
90
+ // }
91
+
92
+ return lastType || type ;
75
93
} ;
76
94
77
95
export const resolveType = ( type , options = { } ) => {
You can’t perform that action at this time.
0 commit comments