mirror of
https://github.com/airbnb/javascript.git
synced 2026-01-14 06:48:05 -05:00
Merge pull request #1083 from airbnb/react-props
Add rule to avoid misusing DOM component prop names
This commit is contained in:
@@ -127,6 +127,19 @@
|
||||
return WithFoo;
|
||||
}
|
||||
```
|
||||
|
||||
- **Props Naming**: Avoid using DOM component prop names for different purposes.
|
||||
|
||||
> Why? People expect props like `style` and `className` to mean one specific thing. Varying this API for a subset of your app makes the code less readable and less maintainable, and may cause bugs.
|
||||
|
||||
```jsx
|
||||
// bad
|
||||
<MyComponent style="fancy" />
|
||||
|
||||
// good
|
||||
<MyComponent variant="fancy" />
|
||||
```
|
||||
|
||||
## Declaration
|
||||
|
||||
- Do not use `displayName` for naming components. Instead, name the component by reference.
|
||||
|
||||
Reference in New Issue
Block a user