React-hot-loader: [v3] Change in componentWillMount doesn't make a reload with lazy loading

Created on 27 Feb 2017  路  5Comments  路  Source: gaearon/react-hot-loader

Description

What you are reporting: bug

Expected behavior

lazy modules should update like usual modules

Actual behavior

they doesn't update

Environment

React Hot Loader v3

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

  1. node -v: v7.4.0
  2. npm -v: 4.0.5

Then, specify:

  1. Operating system: Ubuntu MATE
  2. Browser and version: Chrome 56.0.2924.87 (64-bit)

Reproducible Demo

https://github.com/mqklin/hot-loader-lazy-modules-bug

bug

All 5 comments

I investigated this issue and it seems like it's caused by componentWillMount function:
https://github.com/mqklin/hot-loader-lazy-modules-bug/blob/1dc695dbe9d1f5665882449b47c0676849895a57/src/App.js#L10.

The problem is that once your component is loaded, componentWillMount will not be called again when you don't have any changes while updating. And this is how RHL actually works at the moment.

Please try to follow lazy loading react guide on a webpack site (https://webpack.js.org/guides/lazy-load-react/) and let us know if it works for you.

That code is so verbose... I'm sure it's work, but I don't want to use it. I got the point that I should call require somewhere every time component updates.
I included require('./Lazy'); inside componentWillReceiveProps and it works now:

componentWillReceiveProps() {
  if (__DEV__) require('./Lazy');
}

You said:

And this is how RHL actually works at the moment.

Will this change in the future?

Probably we should consider a case when some run-only-once method has a dependency on some other module that was hot updated and then provide a full reload for that component when async.

Thanks for the bug label. I hope this will be fixed someday.

All of this is outdated. I close it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lemonmade picture lemonmade  路  3Comments

Opty1712 picture Opty1712  路  4Comments

mtscout6 picture mtscout6  路  3Comments

mattkrick picture mattkrick  路  3Comments

sandysaders picture sandysaders  路  4Comments