diego3g / electron-typescript-react

:electron: An Electron boilerplate including TypeScript, React, Jest and ESLint.
1.44k stars 298 forks source link

Add fast refresh (hot reload) #52

Open diego3g opened 3 years ago

diego3g commented 3 years ago

I didn't manage to include fast refresh keeping state through updates inside React yet.

ghost commented 3 years ago

@diego3g Did you try electron-reload this will hot reload window on folder content changed eg:

if (isDev) {
  require("electron-reload")(path.join(__dirname, "public"), {
    electron: require(`${__dirname}/node_modules/electron`),
  });
}
diego3g commented 3 years ago

Hey @Abdallah-Moh, we already have live reload. I want do add React Fast Refresh that keep react state between file changes.

ghost commented 3 years ago

@diego3g you will need to disable the live reload and update the DOM instead

CGamesPlay commented 2 years ago

Just got this working. Requires "@electron-forge/plugin-webpack": "6.0.0-beta.60", because of https://github.com/electron-userland/electron-forge/pull/2444. Then you can add something similar to this to package.json:

          "@electron-forge/plugin-webpack",
          {
            "devServer": {
              "liveReload": false,
              "hot": true
            },

And from there follow the normal installation instructions according to react-refresh-webpack-plugin.

Note that you have to manually list HotModuleReplacementPlugin in your plugins, or else it won't be detected.