Skip to content

Commit 94ace27

Browse files
Gil Birmangilbox
Gil Birman
authored andcommitted
Allow arrow functions in JSX props
1 parent 8db205c commit 94ace27

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

packages/eslint-config-airbnb/rules/react.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ module.exports = {
4141
// Prevent usage of .bind() and arrow functions in JSX props
4242
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md
4343
'react/jsx-no-bind': [2, {
44-
'ignoreRefs': false,
45-
'allowArrowFunctions': false,
44+
'ignoreRefs': true,
45+
'allowArrowFunctions': true,
4646
'allowBind': false,
4747
}],
4848
// Prevent duplicate props in JSX

react/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,23 @@
274274

275275
## Methods
276276

277+
- Use arrow functions to close over local variables.
278+
279+
```javascript
280+
function ItemList(props) {
281+
return (
282+
<ul>
283+
{props.items.map((item, index) => (
284+
<Item
285+
key={item.key}
286+
onClick={() => doSomethingWith(item.name, index)}
287+
/>
288+
))}
289+
</ul>
290+
);
291+
}
292+
```
293+
277294
- Bind event handlers for the render method in the constructor. eslint: [`react/jsx-no-bind`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md)
278295

279296
> Why? A bind call in the render path creates a brand new function on every single render.

0 commit comments

Comments
 (0)