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

121
Views
Why does adding/removing curly braces in this arrow function cause the text to not display for a ReactJS component?
    const tasks = [
    {
        id: 1,
        text: 'Doctors Appointment',
        day: "Feb 5th at 2:30 pm",
        reminder: true,
    },
    {
        id: 2,
        text: "Meeting at School",
        day: "Feb 6th at 1:30pm",
        reminder: true,
    },
    {
        id: 3,
        text: "Food Shopping",
        day: "Feb 5th at 2:30pm",
        reminder: false,
    },
];

    const Tasks = () => {
    return (
        <>
            {
                
                    tasks.map((task) =>
                        <h3>{task.text}</h3>
                )
            }
        </>
    )
}

export default Tasks;

This is my component. Initially I had curly braces in the arrow function, so it looked like this:

tasks.map((task) => {
                        <h3>{task.text}</h3>
                    }

However, doing so made the text disappear. So I removed these curly braces and suddenly the text appeared.

Why does adding curly braces break this arrow function?

Thanks!

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You need return keyword in case you use curly braces in your arrow function.

tasks.map((task) => {
                       return <h3>{task.text}</h3>
                    }
)
about 4 years ago · Juan Pablo Isaza Report

0

Curly braces are used to delimit the function body, therefore you need a return statement for return a value:

tasks.map((task) => {
  return <h3>{task.text}</h3>
})
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!