Skip to content

Commit b7e0a2e

Browse files
committed
Add code to enable debuggin remotely
1 parent b03e81e commit b7e0a2e

3 files changed

Lines changed: 37 additions & 0 deletions

File tree

declaration.d.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
interface Window {
2+
__DEV__: boolean;
3+
}
4+
5+
declare module "react-native" {
6+
export const NativeModules: NativeModules;
7+
export const DevSettings: DevSettings;
8+
}
9+
10+
interface NativeModules {
11+
DevSettings: {
12+
setIsDebuggingRemotely: (isDebuggingRemotely: boolean) => void;
13+
};
14+
}
15+
16+
interface DevSettings {
17+
addMenuItem: (title: string, handler: () => void) => void;
18+
}

index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { NativeModules, DevSettings } from "react-native";
2+
3+
// Tested with React Native 0.71
4+
if (window.__DEV__) {
5+
DevSettings.addMenuItem("* Debug with Chrome", () => {
6+
NativeModules.DevSettings.setIsDebuggingRemotely(true);
7+
});
8+
DevSettings.addMenuItem("* Stop Debugging", () => {
9+
NativeModules.DevSettings.setIsDebuggingRemotely(false);
10+
});
11+
}

package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "react-native-devsettings",
3+
"version": "1.0.0",
4+
"main": "index.js",
5+
"repository": "git@github.com:gusgard/react-native-devsettings.git",
6+
"author": "Gustavo Gard <gusgard@gmail.com>",
7+
"license": "MIT"
8+
}

0 commit comments

Comments
 (0)