-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathRemoteDebugging.tsx
More file actions
46 lines (40 loc) · 1.23 KB
/
Copy pathRemoteDebugging.tsx
File metadata and controls
46 lines (40 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import React from "react";
import { NativeModules, View } from "react-native";
import { getHermesVersion, isBridgeless } from "./core";
import { Feature } from "./Feature";
import { useStyles } from "./styles";
function isRemoteDebuggingAvailable(): boolean {
return (
!getHermesVersion() &&
!isBridgeless() &&
typeof NativeModules["DevSettings"]?.setIsDebuggingRemotely === "function"
);
}
function setRemoteDebugging(value: boolean) {
if (isRemoteDebuggingAvailable()) {
NativeModules["DevSettings"].setIsDebuggingRemotely(value);
}
}
// TODO: Remove this component when we drop support for <0.79
export function RemoteDebugging(): React.ReactElement | null {
const styles = useStyles();
if (!isRemoteDebuggingAvailable()) {
return null;
}
// Remote debugging was removed in 0.79:
// https://github.com/facebook/react-native/commit/9aae84a688b5af87faf4b68676b6357de26f797f
try {
const {
isAsyncDebugging,
} = require("react-native/Libraries/Utilities/DebugEnvironment");
return (
<View style={styles.group}>
<Feature value={isAsyncDebugging} onValueChange={setRemoteDebugging}>
Remote Debugging
</Feature>
</View>
);
} catch (_) {
return null;
}
}