From 986af1f410988e349f39460971953a4befc95021 Mon Sep 17 00:00:00 2001 From: Adam Eivy Date: Sun, 21 Jun 2026 08:34:58 -0700 Subject: [PATCH] fix: dedupe react/react-dom in Vite to stop duplicate-copy hook crash portos-ai-toolkit declares react/react-dom@^18 as optional peers, so npm hoists react@18 to the root node_modules while the app uses react@19 under client/node_modules. Hoisted packages such as react-router-dom then resolve the root react@18, loading two copies of React in the browser and crashing with 'Invalid hook call' / useRef on null (blank page). resolve.dedupe forces every bare react/react-dom import to the single client copy. --- client/vite.config.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/client/vite.config.ts b/client/vite.config.ts index 528badd..dedc646 100644 --- a/client/vite.config.ts +++ b/client/vite.config.ts @@ -4,6 +4,15 @@ import tailwindcss from '@tailwindcss/vite'; export default defineConfig({ plugins: [react(), tailwindcss()], + // The monorepo hoists react@18 (pulled in as an optional peer of + // portos-ai-toolkit) to the root node_modules while the app itself uses + // react@19 under client/node_modules. Without deduping, hoisted packages + // such as react-router-dom resolve the root react@18, producing two copies + // of React in the browser ("Invalid hook call" / useRef on null). Force every + // bare react/react-dom import to resolve to the single client copy. + resolve: { + dedupe: ['react', 'react-dom'], + }, server: { host: '0.0.0.0', port: 6373,