简体   繁体   中英

Property .. does not exist on type 'IntrinsicAttributes & ..'

I am attempting to add a custom prop to a custom styled-component:

interface Props {
  image?: string;
  title?: string;
  subtitle?: string;
  background?: string;
}

export function CardWide({
  image, title, subtitle, background
}: Props) {
  return (
    <CardContainer background={background}>

My styled component background that I passed through looks like this:

interface Props {
  background?: string;
}

const Card = styled.div<Props>`
  display: flex;
  flex-direction: row;
  margin-top: 18px;
  width: 100%;
  min-height: 524px;
  background: ${props => props.background}

However, I receive the following error:

在此处输入图像描述

It feels like I've done everything that I needed to, but I am not sure what I am missing.

Does this code sandbox help?

https://codesandbox.io/s/magical-butterfly-4jjo0n?file=/src/App.tsx:312-320

Let me know if you need more help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM