React-hot-loader: v4.0.0 Beta not working with electron

Created on 15 Jan 2018  路  12Comments  路  Source: gaearon/react-hot-loader

If you are reporting a bug or having an issue setting up React Hot Loader, please fill in below. For feature requests, feel free to remove this template entirely.

Description

The HMR doesn't work with electron.

Expected behavior

When changing some html code I expect the electron application to show those modification.

Actual behavior

Nothing is happening

Environment

React Hot Loader version: 4.0.0-beta.14

Run these commands in the project folder and fill in their results:

  1. node -v: v7.10.1
  2. npm -v: 5.4.2

Then, specify:

  1. Operating system: ubuntu 16.04
  2. Browser and version: electron-prebuilt-compile 1.8.2-beta.3

Reproducible Demo

https://github.com/rllola/hmr-example-issue/tree/hello

bug

All 12 comments

Could you please try to setup RHL v4 as v3. Ie with "manual" module.hot.accept/AppContainer in index.js, and without hot.
Maybe self-acceptance is working differently in Electron.

Related #720. So it is not working?

Confirmed. Degradation due to the changes made for #775 - "could not override .render method, as long it read only."

Regardless of regression in beta-14 this example runs perfectly for beta-12/13.
But there is just no HMR event from Electron.
It should print out Got HMR signal!, but it don't.

I have done a little bit more research on it.

I am using electron-forge and I tried to generate a new project using react template. It use by default the v3.0.0 version. It works great.

I updated to version v4.0.0-beta.13 and did the modification to use hot(module)(App) and now it is not working.

When I am activating the debug for electron-compile:require-hook I have the Got HMR signal! message but no modification.

Could it be linked to babel's react-hot-loader/babel plugin ?

Here the example repo : https://github.com/rllola/hmr-example-issue-2

I hope it will help.

For me HRM fires only once. If I will change any file once again - no HRM will be sent.
Also it always does nothing, as you said, but _thinks_ that everything is ok. Internally it does update all required components.
Could you provide a workable (v3) version?

@theKashey Are you using webstorm ? I do receive the signal everytime I make a modification.

It's not related to IDE. But yes - I am using Webstorm. But no - I am running yarn outside of IDE.
So - could you just provide an example for v3, I just need solution without hot.

I was wondering if it wasn't linked to this : https://github.com/gaearon/react-hot-loader/issues/343
One of my colleagues had this problem with webstorm

Here the working branch with v3 (unfortunately it was broking instanceof and we were waiting for v4 which fix it) : https://github.com/rllola/hmr-example-issue-2/tree/v3

Ok. @rllola - I've solve your problem.
RHL v4 do provide hot function, to auto-configure HRM, setting self-acceptance rule for a __module__.
In case of Electron - module.hot sets acceptance for __application__, and you also have to re-require yourself manually - electron just clears the cache.

Solution - take your v3 branch and just install RHL v4. Dont change the code. Just bump version.

I hope it will help. (please confirm)
I'll try to find a proper solution, meanwhile going to create a section in README for Electron.

I confirm it is working.
I am closing this issue then. Thank you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jljorgenson18 picture jljorgenson18  路  3Comments

rockchalkwushock picture rockchalkwushock  路  3Comments

sandysaders picture sandysaders  路  4Comments

JamesIves picture JamesIves  路  4Comments

theKashey picture theKashey  路  4Comments