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

194
Visualizações
react-lazy-load-image-component Getting Error "TypeError: Cannot read properties of undefined (reading 'prototype')"

I'm using the React Testing Library, and when the component I'm rendering contains a LazyLoadImage from "react-lazy-load-image-component" I get the error "TypeError: Cannot read properties of undefined (reading 'prototype')".

Here's a picture of the error I got:

enter image description here

And this is the image of the code snippet in the component that I rendered:

enter image description here

If anyone is experiencing the same thing as me and has found a solution I really appreciate it. Thank you

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I was having the similar kind of error ( Not exactly the same ) and resolved by changing few things.

  1. You are planning of assigning the value to src of LazyloadImage component only if :
    a. It contains image which is inside of meta ( which is intern inside of article ) and you are not sure that all the time these parameters be present.

  2. You have added a logical and condition to check the presence of each element in hierarchy so that there won't be an issue of cannot find an element of undefined

  3. The main thing is what if any of that condition block falls on false condition ?

At that time, your image tag receive src as false ( src accepts the string not boolean )

so,

Instead of <LazyLoadImage src={article && article.meta && article.meta.image} >

use : {article && article.meta && article.meta.image && <LazyLoadImage src={article.meta.image} >}

This will check the existence of src before compiling to the browser.

Hope this helps!

about 4 years ago · Juan Pablo Isaza Relatório
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