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

304
Views
Getting expected to return a value at the end of the arrow function error

I have a function like this, enter image description here

  const isDisplayStaticAndConditionalSwitcher = (fieldNode, window) => {
    const fieldDataSourceCode = fieldNode.getAttribute('DataSourceCode') || [];
    const nodeValues = Object.values(window?.Designer?.nodes); // get the nodes values 
     
    const formDataSourceCode = nodeValues.map((o) => {
      if (o.displayName === 'Form') { return o.props.code; } 
    }).filter((v) => v)[0];

    return fieldDataSourceCode === formDataSourceCode;
  };

I am getting the error, expected to return a value at the end of the arrow function error How should I resolve the issue?

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

0

Your lint rules want you to explicitly return undefined:

nodeValues.map((o) => {
  if (o.displayName === "Form") {
    return o.props.code;
  } else {
    return undefined;
  }
});
about 4 years ago · Juan Pablo Isaza Report

0

The lint error is because of if condition inside map function. you need to return the same value or other in case of if condition fails.

Using map, Expectation from map function to return same length of Array.

const formDataSourceCode = nodeValues.map((o) => {
      if (o.displayName === 'Form') { return o.props.code; }  
      // add the return in case if condition fails.
      return o;
    }).filter((v) => v)[0];

Hope this is helpful.

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!