Configuration of react/jsx-no-bind allows to use arrow functions, while the style guide prohibits it
- Vorherrschende Sprache
- JavaScript
- Sterne
- 148k
- Forks
- 26.6k
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
The current configuration of `react/jsx-no-bind` allows to use arrow functions as event handlers (and ignores the use of bind in DOM components too): https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb/rules/react.js#L104

However, here's what the style guide has to say bout this:
---

---
1. I agree with the guide's argument and belive that it would be best to update the rule configuration to match it. Using arrow function to initialize an event handler creates a brand new function on each render same as `bind()` does, which can lead to unnecessary re-renders.
2. To be honest, I'd even turn `ignoreDOMComponents` to `false` too — it is unclear why DOM components deserve a different treatment. I'd say the reasoning from the style guide fully applies to them too.
3. If, however, there is some reasoning behind these exceptions — then the style guide should probably reflect it.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Beginne bei packages/eslint-config-airbnb/rules/react.js#L104 und vergleiche die Ausnahmen von react/jsx-no-bind mit den Vorgaben des referenzierten JavaScript style guide. Überprüfe die offenen Fragen zu Pfeilfunktionen und DOM-Komponenten; die Aufgabe ist abgeschlossen, wenn Konfiguration und Leitfaden übereinstimmen oder die Begründung für das Beibehalten einer Ausnahme dokumentiert ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- eslint, javascript
- Bereich
- documentation, tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 38/100