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

[React 19] useEffect does not re-fire on hot reload with React 19 and vite #29915

Open
gkiely opened this issue Jun 16, 2024 · 5 comments
Open

Comments

@gkiely
Copy link

gkiely commented Jun 16, 2024

In prior versions of react, saving a file will trigger the components useEffect hooks to run. This does not work for react 19.
This applies to both @vitejs/plugin-react-swc and @vitejs/plugin-react

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

Steps to reproduce:

  • npm i
  • npm run dev
  • open repo and press save in App.tsx
  • console.log will not fire after pressing save
  • npm i react@latest react-dom@latest (installs latest react 18)
  • npm run dev
  • press save in App.tsx
  • console.log will fire

Video reproduction:
https://www.loom.com/share/b493602e3f7244d2948c5bb871531881?sid=c9bdec15-5b87-4375-a659-6c63804cb032

Notes:
I previously opened a ticket here but it is perhaps an issue with react 19: vitejs/vite-plugin-react#335

@prafulla-codes
Copy link

Hey @gkiely -
I'd like to work on this issue

@ArnaudBarre
Copy link

I've looked into it and this happen only with StrictMode enabled.

@eps1lon
Copy link
Collaborator

eps1lon commented Jul 22, 2024

Does this work in React 18?

@ArnaudBarre
Copy link

Yep, React with 18 useEffect runs everytime if the file is updated

@eps1lon
Copy link
Collaborator

eps1lon commented Jul 22, 2024

Can reproduce with the provided repro and also [email protected]. I also double checked by using breakpoints to ensure it's not just console.log being incorrectly silenced.

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

No branches or pull requests

4 participants