如何在真实设备上打开 react-native 的开发菜单 [英] How do I open react-native's dev menu on real device
问题描述
我已经看到了一些边界情况和奇怪的开发者界面.
I have seen already a number of border cases and strange developer interface.
来自摇动你的设备",这真的不切实际,尤其是平板电脑
From the "shake your device", which is really impractical, specially with a tablet
在 Android Studio 中工作以模拟按下按钮.
有一致的方法吗?我们不能使用实习 API 在我们的应用程序中有一个调试按钮来启动诸如 navigator.popUpDevMenu()
之类的菜单吗?
Is there a consistent way to do it? Can't we use a intern API to have a debug button within our app to launch such menu as navigator.popUpDevMenu()
?
如果没有,您如何摇晃平板电脑以使其工作.这是为了解决如何配置真机上的 HMR 也是如此.React Native 确实改善了开发体验,但我会说特定的事情会减慢它的速度.
And if not, how do you shake your tablet to get it working. This is intended to solve How To configure HMR on a real device, too. React native does improve the development experience, but I'd say that particular thing slows it a little bit.
推荐答案
如果您使用的是 mac,有一个名为 Frappe 的方便工具.https://github.com/niftylettuce/frappe
If you are on a mac, there is a handy tool called Frappe. https://github.com/niftylettuce/frappe
您可以在 shell 中使用此命令
You can use this command from the shell
adb shell input keyevent 82
如果还没有运行 react-native run-android
或者在你运行 react-native run-android
后设备断开连接.您需要 重新启用开发服务器端口.您可以运行此命令并使用上一个命令重试
if haven't run react-native run-android
or if the device gets disconnected after you have run the react-native run-android
. You need to re-enable the development server port. You can run this command and try again with the previous command
adb 反向 tcp:8081 tcp:8081
编辑:此解决方案仅适用于 android 设备,并且是上述问题中提出的黑客之一.所以是可以改进的.但是,在发生这种情况之前,它被选为有效答案.
EDIT: this solution only works for android devices and is among the hacks proposed in the question above. So it is improvable. However It is selected as valid answer until this happens.
这篇关于如何在真实设备上打开 react-native 的开发菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!