Skip to content

Commit

Permalink
fixed migrating to create react app doc
Browse files Browse the repository at this point in the history
  • Loading branch information
casprwang authored Jul 23, 2017
1 parent 7ab86ed commit 4640dbf
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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(
<AppContainer>
<Component />
</AppContainer>,
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

Expand Down

0 comments on commit 4640dbf

Please sign in to comment.