gaearon / react-hot-loader

Tweak React components in real time. (Deprecated: use Fast Refresh instead.)
http://gaearon.github.io/react-hot-loader/
MIT License
12.26k stars 801 forks source link

inconsistent documentation #1334

Open havenchyk opened 5 years ago

havenchyk commented 5 years ago

Getting started section says:

Make sure react-hot-loader is required before react and react-dom:
- or import 'react-hot-loader' in your main file (before React)
- or prepend your webpack entry point with react-hot-loader/patch, for example:
// webpack.config.js
module.exports = {
  entry: ['react-hot-loader/patch', './src'],
  // ...
};
If you need hooks support, use @hot-loader/react-dom

On the other hand migrate from create-react-app section doesn't care about order of the import or @hot-loader/react-dom.

Also when I asked @theKashey on twitter about the state of hooks support, he answered that they should "just work" out of the box.

Before I provide a PR, can somebody confirm that

1) order of the import doesn't matter, prepend is not needed 2) docs from create-react-app section are more valid than latest one 3) no additional tweaks via setConfig usually are needed

theKashey commented 5 years ago
  1. Order of imports matters
    • it was crucial to import RHL before React/ReactDOM to prevent cyclic dependency
    • it still has to be imported before your own code
  2. docs from create-react-app section are more valid than latest one
    • they have to be updated, and probably never did
  3. no additional tweaks via setConfig usually are needed
    • 💯, should be zero configuration, and I am using RHL without any extra configuration as well.