Open Dev Menu or reload app without shaking?

后端 未结 7 715
终归单人心
终归单人心 2021-02-07 10:25

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 goo

7条回答
  •  [愿得一人]
    2021-02-07 10:46

    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 (
                {
                    NativeModules.DevMenu.reload();
                }}
                onLongPress={()=>{
                    NativeModules.DevMenu.show();
                }}
                > 
                
                
            )
        }
        else {
            return null;
        }
    
    }
    

提交回复
热议问题