Skip to content

Commit 4582874

Browse files
authored
Merge pull request #478 from aitherios/patch-1
hmr-react: Update code on project config
2 parents 112c6fe + f59b2b2 commit 4582874

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

content/guides/hmr-react.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ To follow along, please add the following dependencies to your `package.json`:
2525
To use HMR, you'll need the following dependencies:
2626

2727
```bash
28-
28+
2929
```
3030

3131
In addition, for the purposes of this walkthrough, you'll need:
@@ -175,20 +175,23 @@ import { AppContainer } from 'react-hot-loader';
175175

176176
import App from './components/App';
177177

178-
const render = () => {
178+
const render = (Component) => {
179179
ReactDOM.render(
180180
<AppContainer>
181-
<App/>
181+
<Component/>
182182
</AppContainer>,
183183
document.getElementById('root')
184184
);
185185
};
186186

187-
render();
187+
render(App);
188188

189189
// Hot Module Replacement API
190190
if (module.hot) {
191-
module.hot.accept('./components/App', render);
191+
module.hot.accept('./components/App', () => {
192+
const NewApp = require('./components/App').default
193+
render(NewApp)
194+
});
192195
}
193196
```
194197

0 commit comments

Comments
 (0)