gpt4 book ai didi

react-native - 如何在不摇晃手机的情况下启用实时重载或热重载?

转载 作者:行者123 更新时间:2023-12-04 22:41:27 33 4
gpt4 key购买 nike

我开始使用 React Native 大约 2 周,有时我需要重新安装应用程序,然后再次摇晃手机并启用实时重新加载。

第一周很有趣,但随后在开发时不得不摇晃手机变得很无聊。

是否有任何配置文件可以将这些开发属性设置为始终启用?

最佳答案

有一个与通过用 3 根手指按下屏幕来打开菜单相关的封闭问题。您可以检查在最新版本(或在 expo 中)是否正常工作:https://github.com/facebook/react-native/issues/10191

还有其他3种解决方案:

1) 您可以在终端中运行 adb shell input keyevent KEYCODE_MENU
2)试试这个:https://github.com/facebook/react-native/issues/10191#issuecomment-328854286

Open RN dev menu

/usr/local/bin/adb shell input keyevent KEYCODE_MENU Reload RN

/usr/local/bin/adb shell input keyevent 82 /usr/local/bin/adb shell input keyevent 66 /usr/local/bin/adb shell input keyevent 66 (reload was not always working without adding the last line)

In Preferences->Keyboard->Keyboard shortcuts you can then map these services to keyboard shortcuts. I added the shortcuts for the context of my editor (Webstorm) and React Native debugger. In these programs I can now press Ctrl+D to show the developer menu and Ctrl+R to reload which works perfectly.



3)或者你可以试试这个(仅限安卓) https://medium.com/delivery-com-engineering/react-native-stop-shaking-your-phone-1f4863140146

  1. Set up an Automator Service by opening Automator, clicking “New Document”, and choosing “Service”.

  2. Find and select the “Run Shell Script” action. Choose “no input” for “Service receives” and enter: /usr/local/bin/adb shell input keyevent 82 If adb is located elsewhere in your system, change the path to adb. You can find out with: $ which adb

  3. Save and remember what name you give the action.

  4. Open “System Preferences”, go to “Keyboard” and select the “Shortcuts” tab. Select “Services” on the left column and find your service by name.
  5. Click where it says “none” and enter the keyboard shortcut you want to use. Make it something unique or it will conflict with an existing shortcut.

Notes: Android only Must be plugged in If you’ve never run the following with this device, run it first before trying the shortcut: $ adb reverse tcp:8081 tcp:8081



希望能帮助到你。

关于react-native - 如何在不摇晃手机的情况下启用实时重载或热重载?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46177482/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com