--- name: EHSAN HMR context crash (false runtime error) description: When the POC throws "useLanguage must be used within a LanguageProvider" but the source is correct, it's a stale HMR state — restart the workflow. --- # "useLanguage must be used within a LanguageProvider" after edits If the EHSAN POC crashes with `useLanguage must be used within a LanguageProvider` (and/or `Invalid hook call ... more than one copy of React`, or `Cannot read properties of undefined`) **while `App.tsx` clearly wraps the tree in `LanguageProvider` and the source is correct**, it is almost always a corrupted Vite Fast Refresh (HMR) state, NOT a code bug. **Root cause:** `src/contexts/LanguageContext.tsx` exports both a component (`LanguageProvider`) and a hook (`useLanguage`) from one file, so Vite logs `Could not Fast Refresh ("useLanguage" export is incompatible)`. After several hot updates the running app ends up with a duplicate React context instance and the hook can't find the provider. **Fix:** restart the `artifacts/ehsan-poc: web` workflow. The built/production app is unaffected — this is dev-only. **How to apply:** before editing source to "fix" such an error, confirm the current files are actually correct (provider present, key exists); if so, just restart the workflow instead of changing code.