From 4640dbf853e8cfd7139696d2fbf479df456335a5 Mon Sep 17 00:00:00 2001 From: Song Wang Date: Sun, 23 Jul 2017 19:07:17 -0400 Subject: [PATCH] fixed migrating to create react app doc issue: https://github.com/gaearon/react-hot-loader/issues/595 reference: https://github.com/wangsongiam/create-react-with-hot-loader.git --- docs/README.md | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/docs/README.md b/docs/README.md index 003e508c7..49e333628 100644 --- a/docs/README.md +++ b/docs/README.md @@ -147,7 +147,7 @@ Hot reloading code is just one line in the beginning and one line in the end of * Run `npm run eject` * Install React Hot Loader (`npm install --save-dev react-hot-loader@next`) * In `config/webpack.config.dev.js`: - 1. Add `'react-hot-loader/patch'` to entry array (anywhere before `paths.appIndexJs`). It should now look like (excluding comments): + Add `'react-hot-loader/patch'` to entry array (anywhere before `paths.appIndexJs`). It should now look like (excluding comments): ```js entry: [ 'react-hot-loader/patch', @@ -156,25 +156,28 @@ Hot reloading code is just one line in the beginning and one line in the end of paths.appIndexJs ] ``` +* Add `AppContainer` to `src/index.js`: +```js +import { AppContainer } from 'react-hot-loader' - 2. Add `'react-hot-loader/babel'` to Babel loader configuration. The loader should now look like: - ```js - { - test: /\.(js|jsx)$/, - include: paths.appSrc, - loader: 'babel', - query: { - cacheDirectory: findCacheDir({ - name: 'react-scripts' - }), - plugins: [ - 'react-hot-loader/babel' - ] - } - } - ``` +function render(Component) { + ReactDOM.render( + + + , + document.getElementById('root') + ) +} + +render(App) -* Add `AppContainer` to `src/index.js` (see `AppContainer` section in [Migration to 3.0 above](https://github.com/gaearon/react-hot-loader/blob/next-docs/docs/README.md#migration-to-30)) +if (module.hot) { + module.hot.accept('./App', () => { + render(App) + }) +} + +``` ## TypeScript