Reputation: 6029
Is it possible to have a react native app to automatically reload in the emulator once I edit the sources and the thing recompiles itself?
Upvotes: 29
Views: 20952
Reputation: 11
use this command from the shell
adb shell input keyevent 82
to get dev menu on android real device.
Upvotes: 0
Reputation: 6833
This is a huge workaround – but it is saving a lot of time and avoiding the frustration of not shaking correctly.
Also it covers the edge case of complete reloading the bundle, not only for live reloading or hot replacement.
We just throw new Error('Want to refresh?')
to prompt the error screen while in development, so we can hit RELOAD
on the bottom.
Beware of the dragons. This is not the most usual move.
Upvotes: 1
Reputation: 5107
You can use hot-reload in the settings for your react native app to automatically reload. you can enable hot-reloading click the "Menu" button on the sidebar inside genymotion.
Upvotes: 3
Reputation: 2522
If you've created your project with react-native init
, then on the simulator, press cmd+ctrl+Z
or Hardware > Shake Gesture
and the Dev Menu will popup.
Just press Enable Live Reload
and Done! :D
EDIT : React Native team does now encourage to user Hot Reloading instead of Live Reload. More info about the difference between those two features here.
Upvotes: 66
Reputation: 6950
Hot Module Reloading (HMR) shipped with RN 0.22 a few days ago, which lets the simulator automatically reload a single screen or other module without reloading the entire app. It's enabled via the same CMD+D / CMD+CTRL+Z / Shake Gesture menu.
Upvotes: 2