LoginSignup
26
21

More than 5 years have passed since last update.

ExpoアプリにReact Native Debuggerをセットアップする方法 [Mac OS用]

Last updated at Posted at 2018-03-11

[2019年3月20日にアップデート]
フルフルの英語記事はこちら

ExpoのアプリでReduxデバッグをしたい時にはReact Native Debuggerがオススメです。React Native DebuggerならChrome Devtools, React Devtools, Redux Devtoolsの三種の神器が一つの画面に集約できます。

Screen Shot 2019-03-20 at 10.15.52.png

1. React Native Debuggerをインストールする。

brew update && brew cask install react-native-debugger

2. React Native Debuggerを開く

open ‘rndebugger://set-debugger-loc?host=localhost&port=19001’

(デフォルトのportは8081ですが、Expoは19001を使っています。)

3. Expoアプリをスタートし、デバッグモードをonにする

npm start

Expo Clientでアプリを開き、フリフリして、Debug Remote JSを選択。
これで、Chrome Devtoolsは繋がっているはずです。

4. React Devtoolsのセットアップ

Docsによれば、実機でアプリを確認する際は、今一歩セットアップが必要な場合があるようです。
Screen Shot 2019-03-20 at 9.42.24.png

setupDevtools.jsのファイルをnode_modules/react-native/Libraries/Core/Devtools/setupDevtools.jsから開き、connectToDevToolsにパスするobjectのprop、"host"に自分のlocal IPを入れます。
1_HPw_QhsAAEgZOr7iMZxkAw.png
Local IPはこのサイトでチェックできます。

5. Redux Devtoolsのセットアップ

window.REDUX_DEVTOOLS_EXTENSIONはデフォルトで与えられているので、Webの時と同様です。
Screen Shot 2019-03-20 at 10.12.24.png

ただし、古いバージョンではデフォルトで与えられていませんでした。その際は、redux-devtools-extensionをnpm iし、以下のようにする。
Screen Shot 2019-03-20 at 10.32.57.png

以上で、セットアップ完了です。

P.S.ネットワークリクエストを見る際は、React DevtoolsとRedux Devtools辺りで、右クリックし、Enable Network Inspectを押してください。
Screen Shot 2019-03-20 at 10.55.59.png

26
21
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
26
21