Skip to content

Commit

Permalink
fix: avoid key collision in React refresh registration (fix #116)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBarre committed Mar 11, 2023
1 parent b5945c9 commit a74dfef
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/plugin-react/src/refreshUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ function registerExportsForReactRefresh(filename, moduleExports) {
if (key === '__esModule') continue
const exportValue = moduleExports[key]
if (exports.isLikelyComponentType(exportValue)) {
exports.register(exportValue, filename + ' ' + key)
// 'export' is required to avoid key collision when renamed exports that
// shadow a local component name: https://github.com/vitejs/vite-plugin-react/issues/116
// The register function has an identity check to not register twice the same component,
// so this is safe to not used the same key here.
exports.register(exportValue, filename + ' export ' + key)
}
}
}
Expand Down

0 comments on commit a74dfef

Please sign in to comment.