You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+40-4Lines changed: 40 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,9 +30,10 @@ npm install react-hot-loader
30
30
31
31
Latest (4.5.0+, beta) version of React-Hot-Loader could be quite 🔥!
32
32
33
-
> RHL will patch React, React-DOM and work with fiber directly
33
+
> RHL will patch React, replace React-DOM by React-🔥-DOM and work with fiber directly
34
34
35
35
* (required) [use webpack plugin](https://github.com/gaearon/react-hot-loader#webpack-plugin) to let RHL patch React-DOM for you.
36
+
* (alternative) [use react-🔥-dom](https://github.com/gaearon/react-hot-loader#react-hot-dom) to use already patched React-DOM.
36
37
* (optional) [set configuration](https://github.com/gaearon/react-hot-loader#setconfigconfig) to `ignoreSFC:true` (this will fix `hook`)
37
38
* (optional) [set configuration](https://github.com/gaearon/react-hot-loader#setconfigconfig) to `pureRender:true` (this will remove side effect from Classes)
38
39
@@ -60,11 +61,17 @@ setConfig({
60
61
61
62
```js
62
63
// App.js
63
-
importReactfrom'react'
64
-
import { hot } from'react-hot-loader'
65
-
64
+
import { hot } from'react-hot-loader/root'
66
65
constApp= () =><div>Hello World!</div>
66
+
exportdefaulthot(App)
67
+
```
68
+
69
+
There is also another version of `hot`, used prior version 4.5.4. Please use a new one,
70
+
as long is it much more resilient to js errors you may make during development.
67
71
72
+
```js
73
+
import { hot } from'react-hot-loader'
74
+
constApp= () =><div>Hello World!</div>
68
75
exportdefaulthot(module)(App)
69
76
```
70
77
@@ -241,6 +248,35 @@ module.exports = {
241
248
}
242
249
```
243
250
251
+
Webpack plugin will also land a "hot" patch to react-dom, making React-Hot-Loader more compliant to [the principles](https://github.com/gaearon/react-hot-loader/issues/1118).
252
+
253
+
## React-🔥-Dom
254
+
255
+
Another way to make RHL more compliant is to use _our_ version of React-Dom - [hot-loader/react-dom](https://github.com/hot-loader/react-dom)
256
+
257
+
It is the same React-Dom, with the same version, just with our patches already landed inside.
258
+
259
+
There is 2 ways to install it:
260
+
261
+
* Use **yarn** name resolution, so `@hot-loader/react-dom` would be installed instead of `react-dom`
262
+
263
+
```
264
+
yarn add @hot-loader/react-dom@npm:react-dom
265
+
```
266
+
267
+
* Use webpack **aliases**
268
+
269
+
```js
270
+
// webpack.conf
271
+
...
272
+
resolve: {
273
+
alias: {
274
+
'react-dom':'@hot-loader/react-dom'
275
+
}
276
+
}
277
+
...
278
+
```
279
+
244
280
### Code Splitting
245
281
246
282
If you want to use Code Splitting + React Hot Loader, the simplest solution is to pick one of our compatible library:
0 commit comments