0.0.2 • Published 7 years ago
babel-plugin-react-webpack-hot v0.0.2
babel-plugin-react-webpack-hot
Will transform this:
import MyComponent from './my-path.js';
/* ... */
ReactDOM.render(
<MyComponent />,
document.getElementById('root'),
);
into this:
import MyComponent from './my-path.js';
/* ... */
(() => {
const AppContainer = require('react-hot-loader').AppContainer;
const renderIt = () => {
ReactDOM.render(
<AppContainer>
<MyComponent />
</AppContainer>,
document.getElementById('root'),
);
}
renderIt();
if (module.hot) {
module.hot.accept(['./my-path.js'], () => renderIt());
}
})();
This is useful if you're looking to use react-hot-loader
and have multiple rendering points thorough your app.
It's also assuming you're using webpack 2 import (with babel es2015 modules transpilation deactivated).