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

195
Views
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
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!