如何在真实设备上打开react-native的dev菜单 [英] 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
您可以从外壳程序使用此命令
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 reverse 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的dev菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!