import React from "react"; import { Link, LinkProps } from "react-router-dom"; const DynamicLink: React.FC = ({ to, children, ...props }) => { // It is a simple element with nothing to link to if (!to) return {children}; // It is intended to be an external link if (typeof to === "string" && /^https?:\/\//.test(to)) return ( {children} ); // Finally, it is an internal link return ( {children} ); }; export default DynamicLink;