Hot Reloading is out now but I am having lots of problems getting it to work.
At first I had the standard module.hot.accept("../reducers", () => {
code in my redux store but that was causing problems. After commenting that code out I started getting Cannot read property 'length' of undefined
.
I created a new project react-native init test
and I get the same error every time a file is changed.
ExceptionsManager.js:61 Cannot read property 'length' of undefined
Is there something that needs to be done in the project to make hot reloading work?
Update
This is still undocumented and causing more problems than its worth. For now I am using redux-persist with live reloading.
First, run the app using react-native run-android on Terminal. Now, shake the Android device which has the running app. Then select the Enable Hot Reloading or Enable Live Reload option from the popup. Save this answer.
The difference between the two is, Live Reloading is gonna reload your entire application. It's just gonna be like, okay, the file changed, reload the entire app. Hot Reloading is not gonna reload your entire application. It's just going to patch the code that was changed and keep the state in your app.
This feature was previously only available when starting the app without the debugger. CSS Hot Reload: You can change CSS files while the app is running, and changes are applied immediately to the running app as you type.
When editing a React component, React Fast Refresh will efficiently only update and re-render that component. This leads to significantly faster hot reload times. In addition, React Fast Refresh will preserve component state during re-renders so you won't need to manually create the same scenario again.
Facebook has finally documented how to use Hot Reloading or Hot Module Replacement.
https://facebook.github.io/react-native/blog/2016/03/24/introducing-hot-reloading.html
The api is slightly different than Webpack
if (module.hot) {
module.hot.accept(() => {
const nextRootReducer = require("../reducers").default;
store.replaceReducer(nextRootReducer);
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With