`module.hot.invalidate` is not a function
See original GitHub issueI am trying this plugin with webpack-dev-server. I followed the instructions to add this plugin to code and also checked example in webpack-dev-server
in examples
directory.
This is my devServer
config:
devServer: {
host: '0.0.0.0',
historyApiFallback: true,
hot: true,
clientLogLevel: 'info',
inline: true,
liveReload: false,
overlay: true,
port: 8080,
},
I am also using following code snippet to use HMR:-
if (module.hot) {
module.hot.accept('./app', () => {
const App = require('./app').default
ReactDOM.render(<App />, root);
})
}
After adding the plugin to my webpack.config.js
, I changed the label text of Input component. (The input component and the component in which it is used both are functional components). I am getting following error:-
TypeError
module.hot.invalidate is not a function
Call Stack
Object.eval
//path of component
eval
//path of component
Object..//path of component
58.009bff0c7f3cf3782d9f.hot-update.js:6:1
__webpack_require__
main.js:794:31
hotApply
main.js:710:14
undefined
main.js:364:22
Issue Analytics
- State:
- Created 3 years ago
- Comments:19 (9 by maintainers)
Top Results From Across the Web
Hot Module Replacement - webpack
When invalidate is called, the dispose handler will be eventually called and fill module.hot.data . If dispose handler is not registered, an empty...
Read more >A Deep Dive into Hot Module Replacement with Webpack ...
The console says that Hot Module Replacement is enabled. By default, it is not. This project is configured to run with HMR.
Read more >Hot Reload doesn't work when starting inside a function #765
I tried placing a console.log inside the function that is passed into hot(module) but the console.log did not fire. Now I'm trying to...
Read more >HMR API - Vite
Vite exposes its manual HMR API via the special import.meta.hot object: ... To indicate that the module is not hot-updatable, use hot.invalidate() ....
Read more >React module loaded as a string with WebPack `asset/source ...
My test component is there tho, so I could mangle it with regex but I'd rather not if I can somehow remove that...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It should be fine - state should be preserved without any problems. If you do hit anything though, you might have to report to Redux instead because it’s most likely that they are “incompatible” with React’s internals.
(I haven’t used
connect
in a while and I assume it does follow thePascalCase
rule for component names within it’s internals)It is a tiny bit different -
devServer
config flags are only read by WDS but not Webpack - so when you create dev builds it won’t kick into action.