Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v3] Change in componentWillMount doesn't make a reload with lazy loading #490

Closed
mqklin opened this issue Feb 27, 2017 · 5 comments
Closed
Labels

Comments

@mqklin
Copy link

mqklin commented Feb 27, 2017

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

@wkwiatek
Copy link
Collaborator

wkwiatek commented Feb 27, 2017

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.

@mqklin
Copy link
Author

mqklin commented Feb 28, 2017

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?

@wkwiatek
Copy link
Collaborator

wkwiatek commented Mar 1, 2017

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.

@wkwiatek wkwiatek changed the title [v3] lazy modules doesn't update with webpack-hot-middleware [v3] Change in componentWillMount doesn't make a reload Mar 1, 2017
@wkwiatek wkwiatek changed the title [v3] Change in componentWillMount doesn't make a reload [v3] Change in componentWillMount doesn't make a reload with lazy loading Mar 1, 2017
@wkwiatek wkwiatek added bug and removed enhancement labels Mar 1, 2017
@mqklin
Copy link
Author

mqklin commented Mar 2, 2017

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

@gregberge
Copy link
Collaborator

All of this is outdated. I close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants