我制作了这个组件
import * as Styled from './styles';
export type HeadingProps = {
children: React.ReactNode | string;
colorDark: boolean;
};
export const Heading = ({ children, colorDark }: HeadingProps) => {
return <Styled.Wrapper colorDark={colorDark}>{children}</Styled.Wrapper>;
};
但是colorDark给出了一个错误
The type '{ children: ReactNode; colorDark: boolean; }' cannot be assigned to type 'IntrinsicAttributes &
有人知道我怎么解决这个问题吗?它是一个div export const Wrapper = styled。h1
;
显然你缺少了样式的组件的类型。
export const Wrapper = styled.h1<{ colorDark: boolean }>`
...
`;