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

287
Visualizações
Property 'id' does not exist on type 'never'. typescript

i've trying to show image from JSON api and then show it to page, i was do it succesfully but for some reason when i go to page i've get this errors

Property 'id' does not exist on type 'never'.
Property 'url' does not exist on type 'never'.
Property 'title' does not exist on type 'never'.

here is the code

 const App = () => {
 const [images, setImages] = useState([]);
 useEffect(() => {
 fetch('https://api.thecatapi.com/v1/images/search?breed_id=abys')
  .then(res => res.json())
  .then(json => setImages(json))
  .catch(err => console.log(err));
}
, []);
return (
<Fragment>
  <div className="App">
    <h1>Image Gallery</h1>
    <div className="image-container">
      {images.map(image => (
        <Image key={image.id} image={image.url} alt={image.title} />
      ))}
    </div>
  </div>
</Fragment>
);
}
about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

You havent declared a type for image in your useState

const [images, setImages] = useState([]);

so it is considered as type never.

What you should do is add an interface eg IImage and then declare it in your useState

export default interface IImage {
  id: number
  url: string
  title: string
}

const [images, setImages] = useState<IImage[]>([]);
about 4 years ago · Santiago Gelvez 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