Search code examples
reactjsarraystypescriptobjectintrinsicattributes

Type X is not assignable to type 'IntrinsicAttributes & Y'


The type of the array of objects looks as follows: MyType: { name: string, age: number }[], props type in component is the same

./Parent.jsx
export const Parent = () => {
  return (
    <Content data={arrOfObj} />
  )
}

./Content.jsx

export const Content: React.FC<MyType> = (data) => {...}

Solution

  • This is probably what you wanted

    <Content data={arrOfObj} /> // warning
    
    const Content: React.FC<{ data: MyType }> = ({ data }) => {...}