gaearon / react-hot-loader

Tweak React components in real time. (Deprecated: use Fast Refresh instead.)

Home Page:http://gaearon.github.io/react-hot-loader/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

difference b/w `export default hot(module)(App);` and `export default hot(App);`

ORESoftware opened this issue · comments

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

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.