useEffect does not re-fire on hot reload with React 19

Open
#335 4 comments 6 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
react, typescript
Domain
frontend

Research direction

Start with the linked reproduction and follow the listed steps, especially switching between @vitejs/plugin-react-swc and @vitejs/plugin-react in vite.config.ts. Compare hot-reload behavior under React 19; done means saving a file causes the affected component's useEffect hooks to run as they did in prior React versions.

Written by the indexing model from the issue text.

Description

bug: upstream plugin: react plugin: react-swc
Describe the bug

Original issue filed here: https://github.com/vitejs/vite-plugin-react/issues/426, also applies to this plugin.

In prior versions of react, saving a file will trigger the components useEffect hooks to run. This does not work for react 19.

Reproduction

https://github.com/gkiely/swc-issue

Steps to reproduce
  • In vite.config.ts, comment out @vitejs/plugin-react-swc and uncomment @vitejs/plugin-react
  • npm i
  • npm run dev

Video example (using @vitejs/plugin-react-swc, but the same behavior is present for @vitejs/plugin-react)
https://www.loom.com/share/b493602e3f7244d2948c5bb871531881?sid=c9bdec15-5b87-4375-a659-6c63804cb032

System Info
System:
    OS: macOS 12.7
    CPU: (10) arm64 Apple M1 Pro
    Memory: 316.34 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 20.2.0 - ~/.volta/tools/image/node/20.2.0/bin/node
    Yarn: 1.22.18 - ~/.volta/tools/image/yarn/1.22.18/bin/yarn
    npm: 10.8.0 - ~/.volta/tools/image/npm/10.8.0/bin/npm
    bun: 1.1.13 - ~/.bun/bin/bun
    Watchman: 2023.04.10.00 - /opt/homebrew/bin/watchman
  Browsers:
    Brave Browser: 114.1.52.129
    Chrome: 125.0.6422.144
    Edge: 125.0.2535.92
    Safari: 17.5
  npmPackages:
    @vitejs/plugin-react: ^4.3.1 => 4.3.1 
    @vitejs/plugin-react-swc: ^3.5.0 => 3.7.0 
    vite: ^5.2.0 => 5.2.13
Used Package Manager

npm

Logs

No response

Validations
Dominant language
TypeScript
Stars
1.2k
Forks
287
Avg merge
1d 17h
Merged PRs (30d)
19

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from vitejs/vite-plugin-react

All issues in vitejs/vite-plugin-react

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.