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.26k stars 801 forks source link

Moving from v3 to v4? #1189

Closed badtant closed 5 years ago

badtant commented 5 years ago

Hi,

I'm moving from v3 to v4 but cant get any updates to work.

  1. added react-hot-loader/babel
  2. removed react-hot-loader/patch webpack/hot/only-dev-server and HotModuleReplacementPlugin
  3. added hot to my most outer component export default hot(ErrorBoundary)
  4. removed AppContainer

My console says this but nothing seems to update.

[WDS] Hot Module Replacement enabled.
[WDS] App updated. Recompiling...
[WDS] App hot update...

Any suggestions?

badtant commented 5 years ago

I'm starting my dev server like this

var WebpackDevServer = require('webpack-dev-server');
var webpack = require('webpack');

var config = require('./webpack.config.dev.js');
var port = 9090;
var compiler = webpack(config);

var server = new WebpackDevServer(compiler, {
    disableHostCheck: true,
    headers: { 'Access-Control-Allow-Origin': '*' },
    hot: true,
    quiet: true,
    publicPath: config.output.publicPath
});

server.listen(port, function serverListen() {
    console.log('==> Webpack dev server running on port %s', port);
});

So I realized i should put HotModuleReplacementPlugin back. But still no updates. My console:

React-Hot-Loader: react-🔥-dom patch is not detected. React 16.6+ features may not work.
[WDS] Hot Module Replacement enabled.
[WDS] App updated. Recompiling...
[WDS] App hot update...
badtant commented 5 years ago

Progress:

  1. I put back webpack/hot/only-dev-server
  2. Moved export default hot to first component below ErrorBoundary

And now it's working :)

theKashey commented 5 years ago

Basically - when moving from v3 to v4 you shall change how you use RHL, not anything webpack related.

Happy you solved your quiz.