Skip to content

Commit a16679b

Browse files
committed
fix: root hot for parcel bundler, fixes #1082
1 parent dd3e5d9 commit a16679b

File tree

5 files changed

+3187
-611
lines changed

5 files changed

+3187
-611
lines changed

Diff for: README.md

+12-18
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,12 @@ npm install react-hot-loader
2828
2929
## 🔥 HOT-LABS 🔥
3030

31-
Latest (4.5.0+, beta) version of React-Hot-Loader could be quite 🔥!
31+
Latest (4.5.0+) version of React-Hot-Loader could be quite 🔥!
3232

3333
> RHL will patch React, replace React-DOM by React-🔥-DOM and work with fiber directly
3434
3535
* (required) [use webpack plugin](https://github.com/gaearon/react-hot-loader#webpack-plugin) to let RHL patch React-DOM for you.
3636
* (alternative) [use react-🔥-dom](https://github.com/gaearon/react-hot-loader#react--dom) to use already patched React-DOM.
37-
* (optional) [set configuration](https://github.com/gaearon/react-hot-loader#setconfigconfig) to `ignoreSFC:true` (this will fix `hook`)
38-
* (optional) [set configuration](https://github.com/gaearon/react-hot-loader#setconfigconfig) to `pureRender:true` (this will remove side effect from Classes)
39-
40-
```js
41-
import { setConfig } from 'react-hot-loader'
42-
43-
setConfig({
44-
ignoreSFC: true, // RHL will be __completely__ disabled for SFC
45-
pureRender: true, // RHL will not change render method
46-
})
47-
```
4837

4938
## Getting started
5039

@@ -66,23 +55,28 @@ const App = () => <div>Hello World!</div>
6655
export default hot(App)
6756
```
6857

69-
3. [Run webpack with Hot Module Replacement](https://webpack.js.org/guides/hot-module-replacement/#enabling-hmr):
70-
71-
```sh
72-
webpack-dev-server --hot
73-
```
74-
7558
### Old API
7659

7760
**Note:** There is also an old version of `hot`, used prior to version 4.5.4. **Please use the new one**,
7861
as it is much more resilient to js errors that you may make during development.
7962

63+
Meanwhile, not all the bundlers are compatible with new `/root` API, for example **[parcel](http://parceljs.org/) is not**.
64+
65+
React-Hot-Load will throw an error, asking you to use the old API, if such incompatibility would be detected.
66+
It is almost the same, but you have to pass `module` inside `hot`.
67+
8068
```js
8169
import { hot } from 'react-hot-loader'
8270
const App = () => <div>Hello World!</div>
8371
export default hot(module)(App)
8472
```
8573

74+
3. [Run webpack with Hot Module Replacement](https://webpack.js.org/guides/hot-module-replacement/#enabling-hmr):
75+
76+
```sh
77+
webpack-dev-server --hot
78+
```
79+
8680
## Limitations
8781

8882
* (that's the goal) React-Hot-Loader would not change the past, only update the present - no lifecycle event would be called on component update.

Diff for: examples/parcel/package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
"start": "parcel index.html"
77
},
88
"devDependencies": {
9+
"babel-core": "^6.26.3",
910
"babel-plugin-transform-class-properties": "^6.24.1",
1011
"babel-preset-env": "^1.6.1",
1112
"babel-preset-react": "^6.24.1",
12-
"parcel-bundler": "^1.4.1"
13+
"parcel-bundler": "^1.12.3"
1314
},
1415
"dependencies": {
15-
"react": "^16.2.0",
16-
"react-dom": "^16.2.0",
17-
"react-hot-loader": "next"
16+
"react": "^16.8.6",
17+
"react-dom": "^16.8.6",
18+
"react-hot-loader": "^4.8.0"
1819
}
1920
}

Diff for: examples/parcel/src/App.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react'
2-
import { hot } from 'react-hot-loader'
2+
import { hot } from 'react-hot-loader/root'
33
import Counter from './Counter'
44

55
const App = () => (
@@ -9,4 +9,4 @@ const App = () => (
99
</h1>
1010
)
1111

12-
export default hot(module)(App)
12+
export default hot(App)

0 commit comments

Comments
 (0)