cdharris / react-app-rewire-hot-loader

Adds the react-hot-loader to your create-react-app via react-app-rewired

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why do we need this?

azulkipli opened this issue · comments

Could you share why do we need this rewire extension to use react-hot-loader?

Thanks

If you're using create-react-app to manage the build, and you want to add features not natively supported, then you need to modify the webpack configs. Unless you want to "eject" from create-react-app taking full control of the webpack configs, you need some way to change the modify the configs, and that's what the rewire extension does. This specific script (this repo) adds react-hot-loader, which is not included with CRA.

You can get a "light version" of hot module reloading with the basic CRA w/o any modifications at all (google module.hot.accept), but it will not preserve local state (setState), for that you need the full react-hot-loader which this repo here provides.

One more thing:
The README forgot to mention that you must modify your package.json as follows:

    "start": "react-app-rewired start",
    "build": "react-app-rewired build",
    "test": "react-app-rewired test --env=jsdom",
    "eject": "react-app-rewired eject"

It is all described in the rewire extension's README.

OK thanks, will try it