Responsive lambda in rendering

Edit: In particular, does the AirBnb example below have some nuance that exempts it from the tslint / SO rule in Ori Drori's comment?

I am using tslint-react as well as AirBnb Change the style of leadership

The AirBnb rule "Use arrow functions to close by local variables" shows the lambda function, which is used in returning (rendering) 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>
  );
}

The tslint-jsx-no-lambda rule seems to say that this is bad.

JSX--Lambda: ( ES2015) . , React , .

, AirBnb , .

!

+4

Source: https://habr.com/ru/post/1666403/


All Articles