Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

208
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!