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

95
Visualizações
used an API. import and in components>DrinkList.js handleTextShow function not running

In my react program i have made a DrinkList.js in which i show the images of drink. but when i start make it clickable using Onclick and passing a function to display its name in console. error start flooding.

import React from "react";

// import index from "./src"

const DrinkList = (props) => {
  const handleTextShow = (drinkDetail) => {
    console.log(drinkDetail.strGlass);
  };
  return (
    <>
      {props.drinks.map((drink, index) => (
        <div>
          <img src={drink.strDrinkThumb} alt="drink" width="300" height="300">
            {/* hello */}
            onClick={() => handleTextShow(handleTextShow)}
          </img>
          {/* <h4> {drink.strInstructions} </h4> */}

          {/* <Details /> */}
        </div>
      ))}
    </>
  );
};

export default DrinkList;

say strGlass is detail strDrinkThumb is photo.

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

0

The problem is that , in handleTextShow function, instead of passing name of drink to want to console, you're passing handleTextShow function as argument, to solve it replace handleTextShow argument with drink name,

onClick={() => handleTextShow(drink.name)}
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