diff --git a/packages/plugin-react/src/refreshUtils.js b/packages/plugin-react/src/refreshUtils.js index 98b2f3af..0ca2b011 100644 --- a/packages/plugin-react/src/refreshUtils.js +++ b/packages/plugin-react/src/refreshUtils.js @@ -26,9 +26,12 @@ function registerExportsForReactRefresh(filename, moduleExports) { } function validateRefreshBoundaryAndEnqueueUpdate(prevExports, nextExports) { - if (!predicateOnExport(prevExports, (key) => !!nextExports[key])) { + if (!predicateOnExport(prevExports, (key) => key in nextExports)) { return 'Could not Fast Refresh (export removed)' } + if (!predicateOnExport(nextExports, (key) => key in prevExports)) { + return 'Could not Fast Refresh (new export)' + } let hasExports = false const allExportsAreComponentsOrUnchanged = predicateOnExport( @@ -36,7 +39,6 @@ function validateRefreshBoundaryAndEnqueueUpdate(prevExports, nextExports) { (key, value) => { hasExports = true if (exports.isLikelyComponentType(value)) return true - if (!prevExports[key]) return false return prevExports[key] === nextExports[key] }, )