Skip to content

Commit daf7854

Browse files
Copilothotlong
andcommitted
fix: add resolve.dedupe for react/react-dom to prevent duplicate instances
In pnpm strict mode, Vite's dependency pre-bundling can create separate React module instances for different dependency chains (e.g. react-router-dom importing its own React copy). This causes "Invalid hook call" errors when Link/useContext tries to access React internals from a different instance than the one rendering. Adding resolve.dedupe ensures all packages resolve to the same physical React module. Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent a61ab29 commit daf7854

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

apps/web/vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export default defineConfig({
1919
plugins: [react(), tailwindcss(), htmlBaseUrl()],
2020
base,
2121
resolve: {
22+
dedupe: ['react', 'react-dom'],
2223
alias: {
2324
'@': resolve(__dirname, 'src'),
2425
},

0 commit comments

Comments
 (0)