Expose React Devtools as a Metro plugin
Summary: This diff turns the DevTools plugin from a normal plugin in a device plugin. The reason for that can be seen at the end of the test plan in the first stack of this diff: Regardless on which client you open the devtools, you are always looking at the react tree of the app that happens to listen at the appropriate port, unrelated to the actively selected app. This diff moves the plugin from being a client plugin to a device plugin, a Metro device plugin to be precisely, as of the latter there is only one and they should typically correspond (which is why we can trigger reload as done in the previous diff) Currently we have a Flipper plugin inside the iOS / Android apps with one purpose: to select different ports to listen to on different devices. But this functionality was never implemented, nor seems there to be much demand for. So these plugin don't offer any actual value. The widely used standalone version of the react devtools (https://www.npmjs.com/package/react-devtools) doesn't offer port customization either, so this limitation seems to be acceptable. To make sure that this change is backward compatible, we make sure to show the metro device if we find metro, regardless whether it is new enough to support log forwarding and reload commands (previously we only showed the device if it has the /events endpoint). The only case I can think of we are killing with this approach is where people are debugging a RN app, but with having metro running. I doubt that is an actual case, but probably rickhanlonii knows more about that. Furthermore this diff makes sure that the devTools can connect to physical android devices. Also, making it to the end of this explanation means that you have done most of the reviewing for this diff. The actual code diff is shorter. Reviewed By: passy Differential Revision: D19878605 fbshipit-source-id: 3f33e59d4f6e4cce39102420f38afee10018999f
This commit is contained in:
committed by
Facebook Github Bot
parent
56297d0cfc
commit
1383260a7c
@@ -7,17 +7,14 @@
|
||||
|
||||
package com.facebook.flipper.plugins.react;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.flipper.core.FlipperConnection;
|
||||
import com.facebook.flipper.core.FlipperObject;
|
||||
import com.facebook.flipper.core.FlipperPlugin;
|
||||
import com.facebook.flipper.core.FlipperReceiver;
|
||||
import com.facebook.flipper.core.FlipperResponder;
|
||||
|
||||
// This plugin is not needed, but kept here for backward compatilibty
|
||||
@Deprecated
|
||||
public class ReactFlipperPlugin implements FlipperPlugin {
|
||||
|
||||
public static final String ID = "React";
|
||||
@Nullable private FlipperConnection mConnection;
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
@@ -25,22 +22,10 @@ public class ReactFlipperPlugin implements FlipperPlugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnect(FlipperConnection connection) {
|
||||
mConnection = connection;
|
||||
connection.receive(
|
||||
"config",
|
||||
new FlipperReceiver() {
|
||||
@Override
|
||||
public void onReceive(final FlipperObject params, FlipperResponder responder) {
|
||||
// set received host and port in react-native
|
||||
}
|
||||
});
|
||||
}
|
||||
public void onConnect(FlipperConnection connection) {}
|
||||
|
||||
@Override
|
||||
public void onDisconnect() {
|
||||
mConnection = null;
|
||||
}
|
||||
public void onDisconnect() {}
|
||||
|
||||
@Override
|
||||
public boolean runInBackground() {
|
||||
|
||||
Reference in New Issue
Block a user