Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

211
Visualizações
Typescript error: is not assignable to type 'IntrinsicAttributes'

I have created this TSX component and am running into an error.


function FeedMain() {
  const posts = [
    {
      id: "123",
      username: "danieljames",
      userImg:
        "https://upload.wikimedia.org/wikipedia/commons/thumb/e/e7/Instagram_logo_2016.svg/768px-Instagram_logo_2016.svg.png",
      img: "https://upload.wikimedia.org/wikipedia/commons/thumb/e/e7/Instagram_logo_2016.svg/768px-Instagram_logo_2016.svg.png",
      caption: "This is AWWESOME",
    },
  ];
  return (
    <>
      <div>
        {posts.map((post) => (
          <>
            <FeedPost key={post.id} id={post.id}/>
          </>
        ))}
      </div>
    </>
  );
}

export default FeedMain;

The error is:

Type '{ key: string; id: string; }' is not assignable to type 'IntrinsicAttributes'. Property 'id' does not exist on type 'IntrinsicAttributes'.

FeedPost:

function FeedPost({ key, id }) {
  return (
    <>
      <h1 key={key}>{id}</h1>
    </>
  );
}

export default FeedPost;

I am unsure how to change the typing so typescript works with the mapping method. The error that occurs is that Type '{}' is missing the following properties from type '{ key: any; id: any; }': key, id

I think I need to make the typing more specific but I am just unsure how to go about this as I am new. Any suggestions would be really welcomed please!

Does anyone have any suggestions!

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda