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

196
Visualizações
React lambda in render

Edit: Specifically, does the AirBnb example below have some nuance that exempts it from the tslint rule/ SO thread in the comment by Ori Drori?

I'm using tslint-react and also following AirBnb's React style guide

AirBnb's rule "Use arrow functions to close over local variables" shows a lambda function being used in the return (render) of a pure stateless component.

function ItemList(props) {
  return (
    <ul>
      {props.items.map((item, index) => (
        <Item
          key={item.key}
          onClick={() => doSomethingWith(item.name, index)} // This ok??
        />
      ))}
    </ul>
  );
}

tslint-react's rule "jsx-no-lambda" seems to say this is a bad thing.

jsx-no-lambda: Creating new anonymous functions (with either the function syntax or ES2015 arrow syntax) inside the render call stack works against pure component rendering. When doing an equality check between two lambdas, React will always consider them unequal values and force the component to re-render more often than necessary.

I'm confused as to the best practice here, and whether AirBnb's style guide has a nuance that exempts it from concern.

Cheers!

over 4 years ago · Santiago Trujillo
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