0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【react native Redux 簡単デバック】`redux-devtools-expo-dev-plugin` 導入方法 in Expo 50

Posted at

はじめに

今回は、react nativeでReduxを使ううえで簡単にデバック可能なredux-devtools-expo-dev-pluginの紹介と導入手順を紹介していきます。

どんなことができるのか

redux-devtools-expo-dev-pluginを使用すると、存在するstoreの状態とその変化を確認できたり(下記画像参照)
スクリーンショット 2024-08-04 22.42.01.png

rtk Queryを使用したweb APIリクエストのレスポンス、リクエストの詳細などを確認することができます。
スクリーンショット 2024-08-04 22.46.06.png

storeをいじった際にいちいちconsole.logで確認する、といった手間がないので、非常に便利なデバックツールです。

導入手順

今回はRedux toolkitが導入されている前提で進めていきます。

1. パッケージのインストール

redux-devtools-expo-dev-pluginをプロジェクトにインストールします。

npm install redux-devtools-expo-dev-plugin

// yarn を使用する場合は↓
yarn add redux-devtools-expo-dev-plugin

configureStoreに設定する

configureStoreに、redux-devtools-expo-dev-pluginを使用するためのenhancersを追記します。

export const store = configureStore({
  // 省略
  enhancers: (getDefaultEnhancers) =>
    getDefaultEnhancers().concat(devToolsEnhancer()),
});

もし、型エラーが出てしまう場合は// @ts-ignoreを一つ上の行に追記してみてください。

Expoアプリを立ち上げ、Dev toolsを選択

RJjPSnpfCqDta0V1722779849_1722779866.png

いつものこの画面が表示されたら、shiftz + mを押下します。

選択肢の中にOpen devtools plugin - redux-devtools-expo-dev-pluginがあったら導入は成功です! 矢印キーでカーソルを合わせて起動します。

スクリーンショット 2024-08-04 23.00.32.png

スクリーンショット 2024-08-04 23.01.10.png

この画面が表示されれば、あとはデバックしていくだけになります。お疲れ様でした!

おわりに

redux-devtools-expo-dev-plugi もとい react native、まだまだ慣れないことは多いですがなかなか便利なもんですね。
また、便利なことや情報が少ないことにかんして記事にしていけたらいいなと思います...

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?