Currently, if there is a compilation error in the code being hot reloaded, I will see an overlay containing information about the errors, as well as a message in the console about these errors. However, after these errors are addressed, hot reloading should continue as normal, but currently isn't.
When I save a piece of code with an error, then fix the error, I should be able to continue editing and hot reloading my application. This works perfectly fine without using react-hot-loader, and just using webpack-hot-middleware.
function render(rootContainer: JSX.Element) {
ReactDOM.render(
<Provider store={store}>
<ConnectedRouter history={history}>
{rootContainer}
</ConnectedRouter>
</Provider>,
document.getElementById('root')
);
}
render(<Routes />);
//configure hot module replacement during development
if(module.hot) {
module.hot.accept('./routes', () => {
const NewRoutes = require('./routes').Routes;
render(<NewRoutes />);
});
}

What actually happens:
When using react-hot-loader with hot(module)( ... ) in my Routes component, my application is no longer able to hot reload after I fix the error. I see the following:

I see the error overlay disappear, but my component does not get updated any more.
React Hot Loader version: 4.3.11
Run these commands in the project folder and fill in their results:
node -v: v8.10.0npm -v: 6.4.1Then, specify:
I can do if necessary
Yeah - it would be great to have a demo.
According to your logs - RHL just didn't setup a new module.hot.accept, and that's strange.
Here is a demo: https://github.com/mjhoffm2/react-demo/tree/2bbdb5bc95e4f322c41ea6ca3150b43309286a81/node
You should just be able to clone it, go to the 'node' folder, run 'npm install' and 'npm run dev'. React Hot Loader seems like it is working just fine until it tries to hot reload something with an error. For example, adding some random words at the bottom of the Counter.tsx component will break it. Things like TypeScript errors are recoverable.
So - this is actually 3 different things:
errorReporter), as result - if any error took a place - 馃挜 , see #811. Probably we need provide some build-in ErrorBoundary.hoc to receive all possible updates.hot will not be called, and next updates would not be accepted. Patch here is possible, but will require some severe changes in API.Only .3 is a problem. Here is the proposal how to solve it:
import 'react-hot-loader/hot' in the beginning of a file.react-hot-loader/hot would delete itself from a webpack cache(__webpack_require__.c)__webpack_require__.c[module.parents[0]].hot.accept) using the same hot RHL provides for everyone.Any updates on this? Would like to implement this into a boilerplate I've built, but with the inability to resume past an error (without a refresh), this module seems rather limited in usage.
Sorry, trying to solve React 16.6 and 16.7 issues first.
Anyway - a lot of fixes will be released soon.
import {hot} from 'react-hot-loader/root'
...
export default hot(MyComponent);// A DIFFERENT API CALL HERE!!
would solve the problem
This works great, thanks!
import {hot} from 'react-hot-loader/root' ... export default hot(MyComponent);// A DIFFERENT API CALL HERE!!would solve the problem
This doesn't work for me :C
I first had something like this:
import {hot} from 'react hot loader'
...
export default hot(module)(myComponent);
Then I changed it to how you said but it still stops
/root API is proven to work for __webpack only__. If it does not work for you - feel free to provide some details to help us understand "why", and "how" to help you.
Well on my dev configuration for wepack I have this for js|jsx files:
rules: {
test: /\.(js|jsx)$/,
exclude: /(node_modules|bower_components)/ //Here I once changed it so I include node_modules
use: [
{ loader: 'babel-loader', options: { presets: ['@babel/env'] } },
//Here I added loader: 'react-hot-loader/webpack'. But it said it couldn't be found (after running app)
],
},
In .babelrc file I have:
{
"presets": ["@babel/env", "@babel/preset-react"],
"plugins": ["react-hot-loader/babel"]
}
And on the App.js I have this:
import {hot} from 'react-hot-loader/root';
import React....
class App extends Component...
export default hot(App);
But if I have a syntaxis error there and then fix it, the HMR stops, saying that it needs a full reload or something like that.
EDIT: I migrated to this after using hot(module)(App)
Could you please set a breakpoint at the error location, and try to understand why its throwing the exception.
The "old" API was usingmodule.hotfrom the module you provided, a "new" one is accessing yourmoduleviaroot` module "parent", which (according to condition) does not exist)
Most helpful comment
would solve the problem