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

151
Visualizações
return of a function inside a render method is undefined

I have a code that kinda looks like this: (I'm omitting some things but...)

render() {
(bunch of props and state)
 return (
  <div>
   <CustomTabs>
    {this.renderTabs()}
   </CustomTabs>
  </div>
}

Where the renderTabs function looks like this:

 renderTabs = () => {
   const { apps } = this.props;
   apps.filter(app => app?.id !== 'Dashboard').map((app, key) => {
     return <CustomTab label={app.id} key={key} />;
   });
  }

According to some console logs, the filter and mapping is working, so the label and the key exists and are set properly. But the return of the function is undefined.

I note that I'm using MUI datatables to do this and that if I delete the function and add multiple by hand instead, it works properly.

Why is this happening? I have lots of code that looks like this and lots of render methods that call another function to help the rendering and they work without problem.

about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

You need to return the result of filter

about 4 years ago · Santiago Trujillo Relatório

0

You need to return filtered items:

renderTabs = () => {
   const { apps } = this.props;
   return apps.filter(app => app?.id !== 'Dashboard').map((app, key) => {
     return <CustomTab label={app.id} key={key} />;
   });
  }
about 4 years ago · Santiago Trujillo 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