@@ -19,6 +19,7 @@ import {
1919 isTypeBlacklisted ,
2020 registerComponent ,
2121 updateFunctionProxyById ,
22+ isRegisteredComponent ,
2223} from './reconciler/proxies'
2324import configuration from './configuration'
2425import logger from './logger'
@@ -59,6 +60,17 @@ const updateForward = (target, { render }) => {
5960}
6061
6162export const hotComponentCompare = ( oldType , newType , setNewType ) => {
63+ if ( oldType === newType ) {
64+ return true
65+ }
66+
67+ if (
68+ ( isRegisteredComponent ( oldType ) || isRegisteredComponent ( newType ) ) &&
69+ resolveType ( oldType ) !== resolveType ( newType )
70+ ) {
71+ return false
72+ }
73+
6274 if ( isForwardType ( { type : oldType } ) && isForwardType ( { type : newType } ) ) {
6375 if ( areSwappable ( oldType . render , newType . render ) ) {
6476 setNewType ( newType )
@@ -75,10 +87,6 @@ export const hotComponentCompare = (oldType, newType, setNewType) => {
7587 return false
7688 }
7789
78- if ( oldType === newType ) {
79- return true
80- }
81-
8290 if ( areSwappable ( newType , oldType ) ) {
8391 const unwrapFactory = newType [ UNWRAP_PROXY ]
8492 const oldProxy = unwrapFactory && getProxyByType ( unwrapFactory ( ) )
@@ -142,14 +150,19 @@ const reactHotLoader = {
142150 // component got replaced. Need to reconcile
143151 incrementGeneration ( )
144152
145- if ( isTypeBlacklisted ( type ) || isTypeBlacklisted ( proxy . getCurrent ( ) ) ) {
146- logger . error (
147- 'React-hot-loader: Cold component' ,
148- uniqueLocalName ,
149- 'at' ,
150- fileName ,
151- 'has been updated' ,
152- )
153+ if ( ! reactHotLoader . IS_REACT_MERGE_ENABLED ) {
154+ if (
155+ isTypeBlacklisted ( type ) ||
156+ isTypeBlacklisted ( proxy . getCurrent ( ) )
157+ ) {
158+ logger . error (
159+ 'React-hot-loader: Cold component' ,
160+ uniqueLocalName ,
161+ 'at' ,
162+ fileName ,
163+ 'has been updated' ,
164+ )
165+ }
153166 }
154167 }
155168
0 commit comments