Create hello world React app with hot module replacement
This commit is contained in:
11
src/app.js
Normal file
11
src/app.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import React from 'react';
|
||||
|
||||
export default class Site extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
Hello React!
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
22
src/index.js
Normal file
22
src/index.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import 'react-hot-loader/patch';
|
||||
import { AppContainer } from 'react-hot-loader';
|
||||
|
||||
import App from './app';
|
||||
|
||||
|
||||
const render = Component => {
|
||||
ReactDOM.render(
|
||||
<AppContainer>
|
||||
<Component />
|
||||
</AppContainer>,
|
||||
document.getElementById('root')
|
||||
)
|
||||
}
|
||||
|
||||
render(App)
|
||||
|
||||
if (module.hot) {
|
||||
module.hot.accept('./app', () => { render(App) })
|
||||
}
|
Reference in New Issue
Block a user