format and remove unused externallink component

This commit is contained in:
Jorrin
2024-02-03 21:38:58 +01:00
parent d261779b6d
commit a56dac54fe
5 changed files with 9 additions and 39 deletions

View File

@@ -1,30 +0,0 @@
import React from "react";
import { Platform } from "react-native";
import { Link } from "expo-router";
import * as WebBrowser from "expo-web-browser";
export function ExternalLink(
props: Omit<React.ComponentProps<typeof Link>, "href"> & { href: string },
) {
return (
<Link
hrefAttrs={{
// On web, launch the link in a new tab.
target: "_blank",
}}
{...props}
// @ts-expect-error href is not a valid prop for Link, but we're using it here to pass the URL to the web browser.
href={props.href}
onPress={(e) => {
if (Platform.OS !== "web") {
// Prevent the default behavior of linking to the default browser on native.
e.preventDefault();
// Open the link in an in-app browser.
WebBrowser.openBrowserAsync(props.href).catch((error) => {
console.error("Failed to open browser", error);
});
}
}}
/>
);
}

View File

@@ -5,12 +5,12 @@
"baseUrl": ".",
"paths": {
"~/*": ["./src/*"],
"~/components/*": ["./src/app/components/*"]
"~/components/*": ["./src/app/components/*"],
},
"jsx": "react-native",
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json",
"types": ["nativewind/types"]
"types": ["nativewind/types"],
},
"include": ["src", "*.ts", "*.js", ".expo/types/**/*.ts", "expo-env.d.ts"],
"exclude": ["node_modules"]
"exclude": ["node_modules"],
}