Skip to content

Commit d0f83dd

Browse files
authored
chore: handle remote debugging being removed (#2379)
1 parent 5dbcab9 commit d0f83dd

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

example/App.tsx

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import {
1414
// @ts-expect-error no type definitions available
1515
import { version as coreVersion } from "react-native/Libraries/Core/ReactNativeVersion";
1616
import { Colors, Header } from "react-native/Libraries/NewAppScreen";
17-
// @ts-expect-error no type definitions available
18-
import { isAsyncDebugging } from "react-native/Libraries/Utilities/DebugEnvironment";
1917

2018
declare global {
2119
export const RN$Bridgeless: boolean;
@@ -186,20 +184,31 @@ function Separator(): React.ReactElement {
186184
return <View style={styles.separator} />;
187185
}
188186

187+
// TODO: Remove this component when we drop support for <0.79
189188
function DevMenu(): React.ReactElement | null {
190189
const styles = useStyles();
191190

192191
if (!isRemoteDebuggingAvailable()) {
193192
return null;
194193
}
195194

196-
return (
197-
<View style={styles.group}>
198-
<Feature value={isAsyncDebugging} onValueChange={setRemoteDebugging}>
199-
Remote Debugging
200-
</Feature>
201-
</View>
202-
);
195+
// Remote debugging was removed in 0.79:
196+
// https://github.com/facebook/react-native/commit/9aae84a688b5af87faf4b68676b6357de26f797f
197+
try {
198+
const {
199+
isAsyncDebugging,
200+
} = require("react-native/Libraries/Utilities/DebugEnvironment");
201+
202+
return (
203+
<View style={styles.group}>
204+
<Feature value={isAsyncDebugging} onValueChange={setRemoteDebugging}>
205+
Remote Debugging
206+
</Feature>
207+
</View>
208+
);
209+
} catch (_) {
210+
return null;
211+
}
203212
}
204213

205214
export function App(props: AppProps): React.ReactElement<AppProps> {

0 commit comments

Comments
 (0)