Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest Vite version HMR does not work with router #532

Closed
maxwellwalin opened this issue Feb 14, 2023 · 3 comments
Closed

Latest Vite version HMR does not work with router #532

maxwellwalin opened this issue Feb 14, 2023 · 3 comments

Comments

@maxwellwalin
Copy link

Describe the bug

When using the latest version of Vite (npm create vite@latest --template react-ts), router throws reference error as if there was circular dependency or something similar.

If I downgrade the Vite version / vite react plugin version to the version given in the stackblitz template (2.X, 1.X, respectively), it all works fine.

[ReferenceError: Cannot access](client.ts:113 ReferenceError: Cannot access 'homeLayout' before initialization)

Your Example Website or App

https://stackblitz.com/edit/github-4pq3ja?file=package.json

Steps to Reproduce the Bug or Issue

  1. Go to 'src/pages/home/Dashboard'.
  2. After forking, try to change the content on the page.
  3. You will see HMR error in the console.

Expected behavior

No error occurs.

Screenshots or Videos

No response

Platform

  • OS: Windows 10
  • Browser: Chrome

Additional context

No response

@maxwellwalin
Copy link
Author

After messing with this a bit, I narrowed down cause of the issue to be v3.X of @vitejs/plugin-react causing this issue specifically with this package. The issue does not persist with other packages, like react-router. If you downgrade @vitejs/plugin-react to 2.X or below, this issue is resolved. This will be my temporary solution for now.

@judicaelandria
Copy link
Contributor

#510

@tannerlinsley
Copy link
Collaborator

Tracking in #510

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants