-
-
Save gaearon/06bd9e2223556cb0d841 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var App = require('./App') | |
var React = require('react') | |
var ReactDOM = require('react-dom') | |
// Render the root component normally | |
var rootEl = document.getElementById('root') | |
ReactDOM.render(<App />, rootEl) | |
// Are we in development mode? | |
if (module.hot) { | |
// Whenever a new version of App.js is available | |
module.hot.accept('./App', function () { | |
// Require the new version and render it instead | |
var NextApp = require('./App') | |
ReactDOM.render(<NextApp />, rootEl) | |
}) | |
} |
This is the right receipt for hot reloadable pure apps, aka apps with stateless components and the app state stored elsewhere.
Super nice.
React Native version would be nice.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
that was the best starting point on finding out how to implement hmr for something else then react, thank you very much!