This code is related to Webpack’s hot module replacement feature (HMR). module.hot
works like this:
module.hot.accept(
dependencies, // Either a string or an array of strings
callback // Function to fire when the dependencies are updated
);
So the code you included does this: *when the code of ./dashApp.js
or one of the module it requires/imports in the requirement/import tree gets updated, re-render the whole React app.
The hot
property on node modules it not standard, thus the TS error – make sure you install the required type definitions! npm install --save-dev @types/webpack-env
should do the trick.
Related reads:
- Hot Module Replacement concept: high-level Webpack doc on HMR
- Hot Module Replacement API low-level Webpack doc on HMR, explaining how to use it and how does
module.hot.accept
does - Property ‘hot’ does not exist on type ‘NodeModule’: Github issue resolving the TS error