From ec2e4adfcc8b2a80182651bb58748ed5454b0b82 Mon Sep 17 00:00:00 2001 From: Emmanuel Vilsbol Date: Wed, 3 Apr 2019 19:07:05 +0200 Subject: [PATCH 1/3] update usage instructions since v4.5.4 react-hot-loader has changed api from `hot(module)(App)` to `hot(App)`. we update the README to reflect the change. --- README.md | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ad5fc16..f2fd049 100644 --- a/README.md +++ b/README.md @@ -30,9 +30,23 @@ module.exports = function override (config, env) { 2. Follow 'step 2' from https://github.com/gaearon/react-hot-loader , replicated below: -```js Mark your root component as hot-exported: -// App.js +```js +// App.js - react-hot-loader >= 4.5.4 +import React from 'react' +import { hot } from 'react-hot-loader/root' + +const App = () =>
Hello World!
+ +export default process.env.NODE_ENV === "development" ? hot(App) : App +``` +__Old version__: Prior to react-hot-loader version 4.5.4. you needed to write `hot(module)(App)`. + +[react-hot-loader](https://github.com/gaearon/react-hot-loader/tree/v4.7.1#getting-started) recommends to use the latest syntax as +_"it is much more resilient to js errors you may make during development."_ + +```js +// App.js - react-hot-loader < 4.5.4 import React from 'react' import { hot } from 'react-hot-loader' From 9dd1c4b41650e1717b6770dd20b3990a3cfa4c79 Mon Sep 17 00:00:00 2001 From: Emmanuel Vilsbol Date: Wed, 3 Apr 2019 19:15:57 +0200 Subject: [PATCH 2/3] Indent and hightlight instruction steps --- README.md | 74 +++++++++++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index f2fd049..502d61a 100644 --- a/README.md +++ b/README.md @@ -16,55 +16,53 @@ npm install --save react-hot-loader ## Usage -1. In the `config-overrides.js` of the root of your project you created for `react-app-rewired` add this code: +1. __In the `config-overrides.js` of the root of your project you created for `react-app-rewired` add this code:__ -```JS -const rewireReactHotLoader = require('react-app-rewire-hot-loader') + ```JS + const rewireReactHotLoader = require('react-app-rewire-hot-loader') -/* config-overrides.js */ -module.exports = function override (config, env) { - config = rewireReactHotLoader(config, env) - return config -} -``` + /* config-overrides.js */ + module.exports = function override (config, env) { + config = rewireReactHotLoader(config, env) + return config + } + ``` -2. Follow 'step 2' from https://github.com/gaearon/react-hot-loader , replicated below: +2. __Follow 'step 2' from https://github.com/gaearon/react-hot-loader , replicated below:__ -Mark your root component as hot-exported: -```js -// App.js - react-hot-loader >= 4.5.4 -import React from 'react' -import { hot } from 'react-hot-loader/root' + Mark your root component as hot-exported: + ```js + // App.js - react-hot-loader >= 4.5.4 + import React from 'react' + import { hot } from 'react-hot-loader/root' -const App = () =>
Hello World!
+ const App = () =>
Hello World!
-export default process.env.NODE_ENV === "development" ? hot(App) : App -``` -__Old version__: Prior to react-hot-loader version 4.5.4. you needed to write `hot(module)(App)`. + export default process.env.NODE_ENV === "development" ? hot(App) : App + ``` + Prior to react-hot-loader version 4.5.4. you needed to write `hot(module)(App)`. [react-hot-loader](https://github.com/gaearon/react-hot-loader/tree/v4.7.1#getting-started) recommends to use the latest syntax as + _"it is much more resilient to js errors you may make during development."_ -[react-hot-loader](https://github.com/gaearon/react-hot-loader/tree/v4.7.1#getting-started) recommends to use the latest syntax as -_"it is much more resilient to js errors you may make during development."_ + ```js + // App.js - react-hot-loader < 4.5.4 + import React from 'react' + import { hot } from 'react-hot-loader' -```js -// App.js - react-hot-loader < 4.5.4 -import React from 'react' -import { hot } from 'react-hot-loader' + const App = () =>
Hello World!
-const App = () =>
Hello World!
+ export default process.env.NODE_ENV === "development" ? hot(module)(App) : App + ``` -export default process.env.NODE_ENV === "development" ? hot(module)(App) : App -``` +3. __Replace 'react-scripts' with 'react-app-rewired' in package.json__ -3. Replace 'react-scripts' with 'react-app-rewired' in package.json - -```json - "scripts": { - "start": "react-app-rewired start", - "build": "react-app-rewired build", - "test": "react-app-rewired test --env=jsdom", - "eject": "react-app-rewired eject" - }, -``` + ```json + "scripts": { + "start": "react-app-rewired start", + "build": "react-app-rewired build", + "test": "react-app-rewired test --env=jsdom", + "eject": "react-app-rewired eject" + }, + ``` That's it, you now have hot reloads! From 23831bf9e1df210c5f205449d4d2e6bcddddc11e Mon Sep 17 00:00:00 2001 From: Emmanuel Vilsbol Date: Wed, 3 Apr 2019 19:22:32 +0200 Subject: [PATCH 3/3] use headers for hightlighting --- README.md | 72 +++++++++++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 502d61a..3cee7b0 100644 --- a/README.md +++ b/README.md @@ -16,53 +16,53 @@ npm install --save react-hot-loader ## Usage -1. __In the `config-overrides.js` of the root of your project you created for `react-app-rewired` add this code:__ +#### 1. __In the `config-overrides.js` of the root of your project you created for `react-app-rewired` add this code:__ - ```JS - const rewireReactHotLoader = require('react-app-rewire-hot-loader') +```js +const rewireReactHotLoader = require('react-app-rewire-hot-loader') - /* config-overrides.js */ - module.exports = function override (config, env) { - config = rewireReactHotLoader(config, env) - return config - } - ``` +/* config-overrides.js */ +module.exports = function override (config, env) { + config = rewireReactHotLoader(config, env) + return config +} +``` -2. __Follow 'step 2' from https://github.com/gaearon/react-hot-loader , replicated below:__ +#### 2. __Follow 'step 2' from https://github.com/gaearon/react-hot-loader , replicated below:__ - Mark your root component as hot-exported: - ```js - // App.js - react-hot-loader >= 4.5.4 - import React from 'react' - import { hot } from 'react-hot-loader/root' +Mark your root component as hot-exported: +```js +// App.js - react-hot-loader >= 4.5.4 +import React from 'react' +import { hot } from 'react-hot-loader/root' - const App = () =>
Hello World!
+const App = () =>
Hello World!
- export default process.env.NODE_ENV === "development" ? hot(App) : App - ``` - Prior to react-hot-loader version 4.5.4. you needed to write `hot(module)(App)`. [react-hot-loader](https://github.com/gaearon/react-hot-loader/tree/v4.7.1#getting-started) recommends to use the latest syntax as - _"it is much more resilient to js errors you may make during development."_ +export default process.env.NODE_ENV === "development" ? hot(App) : App +``` +Prior to react-hot-loader version 4.5.4. you needed to write `hot(module)(App)`. [react-hot-loader](https://github.com/gaearon/react-hot-loader/tree/v4.7.1#getting-started) recommends to use the latest syntax as +_"it is much more resilient to js errors you may make during development."_ - ```js - // App.js - react-hot-loader < 4.5.4 - import React from 'react' - import { hot } from 'react-hot-loader' +```js +// App.js - react-hot-loader < 4.5.4 +import React from 'react' +import { hot } from 'react-hot-loader' - const App = () =>
Hello World!
+const App = () =>
Hello World!
- export default process.env.NODE_ENV === "development" ? hot(module)(App) : App - ``` +export default process.env.NODE_ENV === "development" ? hot(module)(App) : App +``` -3. __Replace 'react-scripts' with 'react-app-rewired' in package.json__ +#### 3. __Replace 'react-scripts' with 'react-app-rewired' in package.json__ - ```json - "scripts": { - "start": "react-app-rewired start", - "build": "react-app-rewired build", - "test": "react-app-rewired test --env=jsdom", - "eject": "react-app-rewired eject" - }, - ``` +```json + "scripts": { + "start": "react-app-rewired start", + "build": "react-app-rewired build", + "test": "react-app-rewired test --env=jsdom", + "eject": "react-app-rewired eject" + }, +``` That's it, you now have hot reloads!