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

306
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 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