Skip to content

v6 rejects React Fast Refresh for files that export both a React component and a static configuration object #1194

@Artur-

Description

@Artur-

Related plugins

Describe the bug

@vitejs/plugin-react v6 rejects React Fast Refresh for files that export both a React component and a static configuration object. Instead of hot-updating the component, the module is invalidated and a full page reload occurs.

This worked in v5 — the same file patterns were hot-refreshed without issues.

Reproduction

https://github.com/Artur-/vite-hmr-config-repro

Steps to reproduce

npm install
npx vite
  1. Open http://localhost:5173
  2. Click "Increment" a few times to set count > 0
  3. touch src/HelloView.tsx
  4. Observe that count resets to 0 (full reload instead of HMR)
  5. Vite outputs
4:08:22 PM [vite] (client) hmr invalidate /src/HelloView.tsx Could not Fast Refresh ("config" export is incompatible). Learn more at https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react#consistent-components-exports

Remove the export const config and edits hot-refresh correctly, preserving count state.

System Info

- `@vitejs/plugin-react`: 6.0.1
- `vite`: 8.0.8
- `react`: 19.2.5

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions