facebook / react

The library for web and native user interfaces.
https://react.dev
MIT License
227.9k stars 46.51k forks source link

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

Open gkiely opened 3 months ago

gkiely commented 3 months ago

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:

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: https://github.com/vitejs/vite-plugin-react/issues/335

prafulla-codes commented 3 months ago

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

ArnaudBarre commented 2 months ago

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

eps1lon commented 2 months ago

Does this work in React 18?

ArnaudBarre commented 2 months ago

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

eps1lon commented 2 months ago

Can reproduce with the provided repro and also next@15.0.0-canary.76. I also double checked by using breakpoints to ensure it's not just console.log being incorrectly silenced.