명령 줄을 통해 Android 장치에서 수동으로 React Native 앱 다시로드
장치를 물리적으로 흔들지 않고 필요에 따라 React Native 앱을 수동으로 강제로 강제하고 싶습니다. (손목 터널이 생겼습니다.)
Live Reload / Hot Reload를 사용할 수 있다는 것을 알고 있습니다. 주문형 명령 줄 솔루션을 찾고 있습니다.
cmd 줄을 사용하여 Android 장치에 명령을 보낼 수 있습니다.
adb shell input text "RR"
이 명령은 Android 장치에 "R"문자를 두 번 입력하도록 지시합니다. 이는 Android에서 다시로드하는 React Native 명령입니다.
이 adb shell
명령에는 다음과 같은 많은 유용한 기능이 있습니다.
개발자 메뉴를 열려면 :
adb shell input keyevent 82
이 트릭을 몰랐을 경우를 대비하여 여기에 게시하십시오.
안드로이드 기기에서 메뉴 버튼 을 길게 누르세요 . 그러면이 메뉴가 나옵니다
tap the reload option and you are good to go
I use the following command. It doesn't reload the app, but it brings up the developper menu on the device, so I can then press the "Reload" option:
adb shell input keyevent KEYCODE_MENU
I develop with a real device (not the emulator) and sending the "double-R" through adb doesn't work (it just shows the keyboard and types 2 Rs).
Add the following script to your package.json:
"android-shake": "adb shell input keyevent 82"
Then you will be able to call
yarn android-shake
If you are looking for ios then checkout my answer on this link
One trick would be to add this command on ~/.bashrc profile in the case you're using unix.
- use your favorite editor (ex: nano on Ubuntu) and type
nano ~/.bashrc
- on the end of file write
alias rnreload='adb shell input text "RR"'
- save it and run
source ~/.bashrc
in order to active it. - Now whenever you need, just type
rnreload
on a terminal.
Next time you enter your computer it should be already done.
Also, there's the possibility to add an other alias as well: alias rnshake='adb shell input keyevent 82'
which "shakes" android. You can use it to access other commands like Hot Reloading, Debugger, Inspector, etc.
Made an autohotkey script to reload and open the menu with keyboard shortcuts.
^+r:: run, %comspec% /c adb shell input text "RR",,hide
^+e:: run, %comspec% /c adb shell input keyevent 82,,hide
ctrl+shift+r to reload ctrl+shift+e to open dev menu
For device you have just to shake your device than a menu appears so click on Reload
If you're on a Mac and using Hammerspoon, you can put the following bit of code in your ~/.hammerspoon/init.lua
file:
hyper = {'ctrl', 'alt', 'cmd'}
placid = {'ctrl', 'cmd'}
-- React native reload JS on connected device
hs.hotkey.bind(placid, 'R', function()
os.execute('/Users/peter/Library/Android/sdk/platform-tools/adb shell input text "RR"')
end)
-- React native show dev menu on connected device
hs.hotkey.bind(hyper, 'R', function()
os.execute('/Users/peter/Library/Android/sdk/platform-tools/adb shell input keyevent 82')
end)
the os.execute
command doesn't load your ENV (doing so would make running commands really slow), so make sure to run which adb
in your terminal to figure out what the exact path to adb
is. (in my case it was /Users/peter/Library/Android/sdk/platform-tools/adb
).
Now you can reload your app using ctrl+cmd+R
and show the dev menu using ctrl+option+cmd+R
from anywhere and without even bothering to cmd-tab out of your favorite editor!
'Programing' 카테고리의 다른 글
NSMutableAttributedString에서 링크 색상 변경 (0) | 2020.11.26 |
---|---|
pip3로 패키지를 설치할 때 "Python의 SSL 모듈을 사용할 수 없습니다" (0) | 2020.11.26 |
UITableView의 테두리를 제거하려면 어떻게합니까? (0) | 2020.11.26 |
Windows에서 Mono의 요점은 무엇입니까? (0) | 2020.11.26 |
MVC RequireHttps 전체 사이트 (0) | 2020.11.26 |