diff --git a/packages/react-refresh/src/ReactFreshRuntime.js b/packages/react-refresh/src/ReactFreshRuntime.js index 56af77a8e8584..3fc56a294e4fa 100644 --- a/packages/react-refresh/src/ReactFreshRuntime.js +++ b/packages/react-refresh/src/ReactFreshRuntime.js @@ -147,8 +147,12 @@ function isReactClass(type) { return type.prototype && type.prototype.isReactComponent; } +function isMobxObserver(type) { + return typeof type === "function" && type.name === "observerComponent" +} + function canPreserveStateBetween(prevType, nextType) { - if (isReactClass(prevType) || isReactClass(nextType)) { + if (isReactClass(prevType) || isReactClass(nextType) || isMobxObserver(nextType)) { return false; } if (haveEqualSignatures(prevType, nextType)) {