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
There is also old version of `hot`, used prior version 4.5.4. **Please use a new one**,
70
-
as it is much more resilient to js errors you may make during development.
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
+
75
+
### Old API
76
+
77
+
**Note:** There is also an old version of `hot`, used prior to version 4.5.4. **Please use the new one**,
78
+
as it is much more resilient to js errors that you may make during development.
71
79
72
80
```js
73
81
import { hot } from'react-hot-loader'
74
82
constApp= () =><div>Hello World!</div>
75
83
exportdefaulthot(module)(App)
76
84
```
77
85
78
-
3.[Run webpack with Hot Module Replacement](https://webpack.js.org/guides/hot-module-replacement/#enabling-hmr):
79
-
80
-
```sh
81
-
webpack-dev-server --hot
82
-
```
83
-
84
86
## Limitations
85
87
86
88
* (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.
@@ -237,11 +239,10 @@ Using React Hot Loader with React Native can cause unexpected issues (see #824)
237
239
238
240
## Webpack plugin
239
241
240
-
We recommend to use `babel` plugin, but there are situations when you are unable to use it, then - try webpack loader (as seen in v3)
241
-
to have at least _something_.
242
-
Remember - it is **not compatible** with class-based components - as long as babel plugin
243
-
would inject a special methods to the every class, to make `class members`(like onClick) hot-updatable,
244
-
while webpack-plugin would leave classes as is, without any _instrumentation_.
242
+
We recommend using the `babel` plugin, but there are some situations where you are unable to. If so, try the `webpack` plugin / `webpack-loader` (as seen in v3).
243
+
244
+
Remember - the `webpack` plugin is **not compatible** with class-based components. The `babel` plugin
245
+
will inject special methods to every class, to make `class members` (like onClick) hot-updatable, while the `webpack` plugin would leave classes as is, without any _instrumentation_.
245
246
246
247
```js
247
248
classMyComponentextendsReact.Component {
@@ -251,7 +252,7 @@ class MyComponent extends React.Component {
251
252
}
252
253
```
253
254
254
-
But webpack-loader could help with TypeScript or _spreading_ "cold API" [to all node_modules](https://github.com/gaearon/react-hot-loader#disabling-a-type-change-for-all-node_modules).
255
+
But `webpack-loader` could help with TypeScript or _spreading_ "cold API" [to all node_modules](https://github.com/gaearon/react-hot-loader#disabling-a-type-change-for-all-node_modules).
255
256
256
257
> It is safe to enable this loader for all the files. But place it after babel-loader, if babel-loader is present.
0 commit comments