How can I avoid full page reloads? #112
-
I seem to get a full page reload no matter what I do. Add a console.log statement to a component? Full page reload. Any idea what could cause this? At the moment, I'm including the react plugin in my vite.config with zero arguments. Here is what I have for plugins: plugins: [
react(),
viteTsconfigPaths(),
svgrPlugin(),
] In my console, I see messages like "hmr update" and "hmr invalidate". I only seem to get "hmr invalidate" when I have an error in my code (in which case, I'd expect a full page refresh), but even when it shows "hmr update", I still get a full page refresh. I thought HMR surgically re-renders only the component I edited (and its children), not the whole app. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
You should update to the latest version of the plugin you will get a message on why the file was invalidated. |
Beta Was this translation helpful? Give feedback.
-
Hi,I have same issue, I didn't quite catch what should i do to prevent all page refresh could you provide me with an answer ? it takes lots of my time for any change. |
Beta Was this translation helpful? Give feedback.
You should update to the latest version of the plugin you will get a message on why the file was invalidated.
There are rules to follow in React to get HMR working: https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react#consistent-components-exports
If you're using eslint, you can try https://github.com/ArnaudBarre/eslint-plugin-react-refresh to find some issues