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

408
Views
Unexpected block statement surrounding arrow body; move the returned value immediately after the `=>` arrow-body-style
const loadUsers = () => {
  return function (dispatch) {
    axios
      .get(`${process.env.REACT_APP_API}`)
      .then((resp) => {
        console.log(resp);
        dispatch(getUsers(resp.data));
      })
      .catch((error) => console.log(error));
  };
};

I'm getting this error in the above code.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

If an arrow function's block only has one return statement, you can omit the block and the return keyword. According to the linter you're using, you need to indeed do that:

const loadUsers = () => function (dispatch) {
  axios
    .get(`${process.env.REACT_APP_API}`)
    .then((resp) => {
      console.log(resp);
      dispatch(getUsers(resp.data));
    })
    .catch((error) => console.log(error));
};
about 4 years ago · Santiago Trujillo 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!