Skip to content

Commit 5f50ee4

Browse files
committed
fix: document the importance of import order, fixes #1209
1 parent 3cd44b0 commit 5f50ee4

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

Diff for: README.md

+14-3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ const App = () => <div>Hello World!</div>
5555
export default hot(App)
5656
```
5757

58+
3. Make sure `react-hot-loader` is required before `react`.
59+
60+
* or `import 'react-hot-loader'` in your main file (before React)
61+
* or have at least one variable in the same file (babel/webpack plugin would import react-hot-loader then)
62+
* or prepend your webpack entry point with `react-hot-loader/patch`, which will `import 'react-hot-loader'`, and nothing more.
63+
64+
Keep in mind - the same rule is applied to `react-dom`, as long as it would (since 16.8.6) import `react` internally.
65+
React-hot-loader, to prevent dependency cycles(#1209), caused by the code it injects, **should be imported first**.
66+
5867
### Old API
5968

6069
**Note:** There is also an old version of `hot`, used prior to version 4.5.4. **Please use the new one**,
@@ -662,10 +671,12 @@ import App from './containers/App'
662671
ReactDOM.render(<App />, document.getElementById('root'))
663672
```
664673

665-
### No patch required
674+
### Patch is optional
675+
676+
> Since 4.0 till 4.8
666677
667-
Code is automatically patched, you can safely remove `react-hot-loader/patch`
668-
from your webpack config.
678+
Code is automatically patched, you can safely remove `react-hot-loader/patch` from your webpack config,
679+
if react-hot-loader is required before React in any other way.
669680

670681
### Error Boundary is inside every component
671682

0 commit comments

Comments
 (0)