React Native Debugger's connect to React not working with Expo Client
Asked Answered
I

0

6

[Update on March 20, 2019: If you have this issue, check out my post here!]

I'm making a mobile app using Expo and React Native. I would like to integrate React Native Debugger to my project for react and redux debugging. But am having trouble.

Specifically connecting to react devtools have failed. I think this is because I am using Expo client (real device connected via wifi).

According to the docs, I should follow this path.

enter image description here

Since my Expo version is 25.0.0, the RN version is 0.52. Therefore, I must edit the setupDevtools.js.

The problem is, this doc is confusing to me. And I'm not sure whether I'm doing the right thing. So far, as below, I have changed the host to my IP address. But this didn't work. I guess I'm doing something wrong. Could anyone help? Thanks in advance.

const host = PlatformConstants && PlatformConstants.ServerHost ?
      PlatformConstants.ServerHost.split(':')[0] :
      'localhost';

    reactDevTools.connectToDevTools({
      isAppActive,
      host: "116.0.157.7",
      // Read the optional global variable for backward compatibility.
      // It was added in https://github.com/facebook/react-native/commit/bf2b435322e89d0aeee8792b1c6e04656c2719a0.
      port: window.__REACT_DEVTOOLS_PORT__,
      resolveRNStyle: require('../../StyleSheet/flattenStyle'),
    });
Interpose answered 10/3, 2018 at 2:14 Comment(3)
Never mind! I have solved this problem. I was not understanding the difference between public IP and local IP. I was putting the public IP as host. Worked when I put the local IP. When you google what is my IP? What you get is the public IP. Rather, go to this site that shows you the local IP as well. (whatismyip.com)Interpose
How do you get to the setupDevtools.js?Atahualpa
node_modules/react-native/Libraries/Core/Devtools/setupDevtools.jsInterpose

© 2022 - 2024 — McMap. All rights reserved.