Код: Выделить всё
import styled from "@emotion/styled";
import { Url } from "next/dist/shared/lib/router/router";
import Link from "next/link";
import { Fragment } from "react";
const ButtonInner = styled.button`
// ... various styles
`;
type Props = React.ComponentProps &
(
| {
as: "a";
href: Url;
}
| {
as?: Exclude;
href?: never;
}
);
export function Button({ as, href, disabled, ...props }: Props) {
const Wrapper = ({ children }: { children: React.ReactNode }) => {
if (as === "a" && !disabled) {
return (
// ^? = Url | undefined
{children}
);
}
return {children};
};
return (
);
}
Подробнее здесь: https://stackoverflow.com/questions/797 ... ot-working
Мобильная версия