react-native-components-inspector
Version:
react native components inspector can used to click the component and open the code in the editor
13 lines (11 loc) • 379 B
text/typescript
import { NativeModules } from 'react-native';
export function getDevServerBaseURL(): string | null {
const scriptURL: string | undefined = (NativeModules as any)?.SourceCode?.scriptURL;
if (!scriptURL) return null;
try {
const url = new URL(scriptURL);
return `${url.protocol}//${url.hostname}${url.port ? `:${url.port}` : ''}`;
} catch {
return null;
}
}