React-hot-loader: difference b/w `export default hot(module)(App);` and `export default hot(App);`

Created on 22 Feb 2020  路  2Comments  路  Source: gaearon/react-hot-loader

In the docs there are two styles:

export default hot(module)(App);

and

export default hot(App);

seems like a big difference and curious as to what it means

Most helpful comment

It is import {hot} from 'react-hot-loader' vs import {hot} from 'react-hot-loader/root'.

The second provides more "magic" out of the box, but works only for webpack. See the code -- https://github.com/gaearon/react-hot-loader/blob/master/root.js

Basically, it setup HMR for the parent module, not the current module - export default hot(moduleParent)(App); - so if in the future the current module will fail to load (like a syntax error) - the "parent" will still able to reload it.

All 2 comments

It is import {hot} from 'react-hot-loader' vs import {hot} from 'react-hot-loader/root'.

The second provides more "magic" out of the box, but works only for webpack. See the code -- https://github.com/gaearon/react-hot-loader/blob/master/root.js

Basically, it setup HMR for the parent module, not the current module - export default hot(moduleParent)(App); - so if in the future the current module will fail to load (like a syntax error) - the "parent" will still able to reload it.

thx

Was this page helpful?
0 / 5 - 0 ratings

Related issues

theKashey picture theKashey  路  4Comments

mattkrick picture mattkrick  路  3Comments

ghost picture ghost  路  3Comments

reintroducing picture reintroducing  路  4Comments

rockchalkwushock picture rockchalkwushock  路  3Comments