Skip to content

Vite fast refresh not working #7419

@gaastonsr

Description

@gaastonsr

Which project does this relate to?

Router

Describe the bug

When using react router v1.170.3 if in my __root.tsx file if I use createRootRouteWithContext to create my route Vite fast refresh doesn't work.

I get the error:

[vite] (client) hmr update /src/css/index.css, /src/routes/__root.tsx
[vite] (client) hmr invalidate /src/routes/__root.tsx Could not Fast Refresh ("Route" export is incompatible). Learn more at https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react#consistent-components-exports

If I use createRootRoute I don't see the error in the terminal.

Complete minimal reproducer

https://stackblitz.com/edit/github-g9yc4r8q-58ibupra?file=src%2Froutes%2F__root.tsx

Steps to Reproduce the Bug

  1. Go to the stackblitz that I created
  2. Update anything in __root.tsx and save the file.
  3. You will see the error in the terminal.

Expected behavior

I shouldn't see that error in the terminal.

Screenshots or Videos

Image

Platform

  • Router Version: v1.170.3
  • OS: macOS
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Browser Version: [e.g. 91.1]
  • Bundler: vite
  • Bundler Version: [e.g. 7.0.0]

Additional context

Seems to be similar to a problem reported in the past: #3815.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions