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

210
Visualizações
Not able to see anything written inside the return component in JSX

I'm new to React and JSX. I'm building a button when clicked opens a dialog box with a table inside it (1x3) which has name, status, & exception error as "strings".

For some reason, when I click the button, I can see the console.log() statement in my console being shown, but nothing shows up as a pop-up dialog box (so, anything and everything inside the return() statement).

  const isFailed = () => {
    console.log(testCase["test-method"][0].status);
        //alert(testCase["test-method"][0].exception);
        return(
          <Dialog maxWidth="xl" open={open} onClose={() => setOpen(false)}>
          <DialogTitle>{testCase.name} Summary</DialogTitle>
          <DialogContent>
            <Table>
              {steps.map((val) => (
                <TableRow key={val.name}>
                  <TableCell>{val.name}</TableCell>
                  <TableCell>{val.status}</TableCell>
                  <TableCell>{val.exception}</TableCell>
                </TableRow>
              ))}
            </Table>
          </DialogContent>
        </Dialog>
        );
  }

EDIT: isFailed function is called by the onClick Button handler

const steps = testCase["test-method"];
  return (
    <>
      <TableRow key={key} style={{ cursor: "pointer" }} onClick={() => setOpen(true)}>
        <TableCell>{testCase.name}</TableCell>
        <TableCell>{testCase.duration}</TableCell>
        <StatusCell fail={testCase.fail} skip={testCase.skip} />
        <TableCell>{(typeof(testCase["test-method"][0].exception) == typeof("string")) ? <div> <Button onClick = {isFailed} color = "primary">View Error</Button> </div>: null}</TableCell>
      </TableRow>
    </>
  );

If someone can help me with this, it will be awesome. Thanks.

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

0

You can't use return method inside a onClick function. You might need to maintain a separate state to handle the onclick function.

const steps = testCase["test-method"];
    return (
        <>
           <TableRow key={key} style={{ cursor: "pointer" }} onClick={() 
        => setOpen(true)}>
             <TableCell>{testCase.name}</TableCell>
             <TableCell>{testCase.duration}</TableCell>
             <StatusCell fail={testCase.fail} skip={testCase.skip} />
             <TableCell>{(typeof(testCase["test-method"][0].exception) == typeof("string")) ? <div> <Button onClick = {isFailed} color = "primary">View Error</Button> </div>: null}</TableCell>
             </TableRow>
         </>
        {isClicked &&
         <Dialog maxWidth="xl" open={open} onClose={() => setOpen(false)}>
            <DialogTitle>{testCase.name} Summary</DialogTitle>
               <DialogContent>
                 <Table>
                     {steps.map((val) => (
                        <TableRow key={val.name}>
                           <TableCell>{val.name}</TableCell>
                            <TableCell>{val.status}</TableCell>
                            <TableCell>{val.exception}</TableCell>
                        </TableRow>
                     ))}
                 </Table>
              </DialogContent>
         </Dialog>
        }
      
     );

On onClick function just set the boolean value of isClicked function.

const [isClicked, setIsClicked] = React.useState(false);

const isFailed = () => {
    setIsClicked(true);
}
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