Skip to content

Commit a74dfef

Browse files
committedMar 11, 2023
fix: avoid key collision in React refresh registration (fix #116)
1 parent b5945c9 commit a74dfef

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed
 

‎packages/plugin-react/src/refreshUtils.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ function registerExportsForReactRefresh(filename, moduleExports) {
2525
if (key === '__esModule') continue
2626
const exportValue = moduleExports[key]
2727
if (exports.isLikelyComponentType(exportValue)) {
28-
exports.register(exportValue, filename + ' ' + key)
28+
// 'export' is required to avoid key collision when renamed exports that
29+
// shadow a local component name: https://github.com/vitejs/vite-plugin-react/issues/116
30+
// The register function has an identity check to not register twice the same component,
31+
// so this is safe to not used the same key here.
32+
exports.register(exportValue, filename + ' export ' + key)
2933
}
3034
}
3135
}

0 commit comments

Comments
 (0)
Please sign in to comment.