gaearon / react-hot-loader

Tweak React components in real time. (Deprecated: use Fast Refresh instead.)
http://gaearon.github.io/react-hot-loader/
MIT License
12.25k stars 801 forks source link

Difference between react-hot-loader, webpack-hot-client, webpack-hot-middleware? #920

Open wzup opened 6 years ago

wzup commented 6 years ago

Description

More explanation

Environment

React Hot Loader version: recent stable

  1. node -v: 8.9.4
  2. npm -v: 5.6.0
  3. Operating system: Ubuntu 16.04.3 LTS, xenial
  4. Browser and version: Chrome 63.0.3239.132 (Official Build) (64-bit)

Question

What is the difference between react-hot-loader and webpack-hot-client (webpack-hot-middleware)?

I'm developing React+Express application. I use Webpack to build assets and compile React. I use webpack-serve as a dev server. This dev server features HMR out-of-the-box (it uses both, webpack-hot-client and webpack-hot-middleware).

Do I need to use react-hot-loader if I use webpack-serve? Why? Could you please explain what exactly react-hot-loader does?

gregberge commented 6 years ago

I think it is a good idea, we have a lot of confusion between these packages.

theKashey commented 6 years ago

react-hot-loader - client side library(+babel plugin), to perform React Component hot-updates. webpack-hot-client - server side library, watches for fs changes and sends updates to a client. webpack-hot-middleware - mixed (more client), some additional code, to make hot-module-replacement work. More concrete - accept updates from webpack-hot-client.

And you need all this stuff, as long react-hot-loader works atop webpack-hot-middleware, which is a part of webpack-hot-client.

fatfatson commented 6 years ago

@theKashey I have made a express server and use only webpack-hot-middleware(&webpack-dev-middleware) but without react-hot-loader, my react component(&mobx store) is already get hot updated. so what's the purpose of react-hot-loader? is it really necessary?

sixiakun commented 4 years ago

@theKashey I have made a express server and use only webpack-hot-middleware(&webpack-dev-middleware) but without react-hot-loader, my react component(&mobx store) is already get hot updated. so what's the purpose of react-hot-loader? is it really necessary?

I didn't get hot updated, but i have this confusion, too

theKashey commented 4 years ago

so what's the purpose of react-hot-loader? is it really necessary?

Keep the state of your application. Global store, local store, hooks, refs, everything. Without RHL you will get no more than full page refresh, potentially keeping some stuff like redux-store defined above hot