pmmmwh / react-refresh-webpack-plugin

A Webpack plugin to enable "Fast Refresh" (also previously known as Hot Reloading) for React components.
MIT License
3.13k stars 192 forks source link

Performs full reload and state loss in case of error #839

Open jaspal-dev opened 3 months ago

jaspal-dev commented 3 months ago

I am using the module version 0.5.13. In case if app found an error (eg. accessing undefined.a ), it looses it state and performs full reload. Is this behaviour is default then how to tackle this one, just like CRA handle it.

pmmmwh commented 3 months ago

Hi, I cannot help unless there's a reproduction of what's happening. Depending on how your modules and code is structured it may or may not fallback to a full reload to ensure consistency.

jaspal-dev commented 3 months ago

Hi

https://github.com/jaspal-dev/weather-app/blob/fix/react-refresh-issue/src/App.jsx Please review this file. In this branch, you can also view the webpack and plugin configuration.

If I change a counter to counter1 or anything else in the file, the changes are reflected in the web app, which is expected.

But if I uncomment the code undefined.a as given in the file for throwing some error, after that, I uncomment it. The page reloads, and the state of the counter is lost.

After fixing any error, the state should be mentioned.