Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open Dev Menu or reload app without shaking?

Tags:

react-native

Is there a way to open dev menu or reload app without shaking the app?

Android Wireless over wifi so no usb cable Windows 10

Hot reload or Live reload is not good enough and my arm hurts :)

like image 518
Benny Avatar asked Mar 27 '18 14:03

Benny


People also ask

How do I open the app developer menu?

In App Developer Menu You can open the developer menu on the IOS simulator by pressing command + D. On Android emulator, you need to press command + M.

How do you shake an emulator?

The Best Answer is. Within your app in the Android Emulator press Command + M on macOS or Ctrl + M on Linux and Windows.


1 Answers

for android : in your package.json add following lines in scripts

 "reload":"adb shell input keyevent 82 && adb shell input keyevent 66 && adb shell input keyevent 66",
 "devmenu":"adb shell input keyevent 82",
 "debug":"adb shell input keyevent 82 && adb shell input keyevent 61 && adb shell input keyevent 66 && adb shell input keyevent 66"

now you can run npm run devmenu to open shake menu in android, and reload to reload the app, and debug to connect to remote debugger.

for ios : you can make a button for it somewhere in app, and let this thing only be shown when app is in dev mode.

import {NativeModules,Platform} from "react-native"


renderDevMenuTouchable = () => {
    if(__DEV__ && Platform.OS == "ios" ){
        return (
            <TouchableOpacity
            style={styles.touchableDebug}
            onPress={()=>{
                NativeModules.DevMenu.reload();
            }}
            onLongPress={()=>{
                NativeModules.DevMenu.show();
            }}
            > 
            <View style={{backgroundColor:"red",width:23,height:25}}/>
            </TouchableOpacity>
        )
    }
    else {
        return null;
    }

}
like image 97
Yash Ojha Avatar answered Sep 28 '22 22:09

Yash Ojha