Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a599bca

Browse files
committed
Add rule to avoid misusing DOM component prop names
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.
1 parent a86d546 commit a599bca

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

react/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,19 @@
127127
return WithFoo;
128128
}
129129
```
130+
131+
- **Props Naming**: Avoid using DOM component prop names for different purposes.
132+
133+
> 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.
134+
135+
```jsx
136+
// bad
137+
<MyComponent style="fancy" />
138+
139+
// good
140+
<MyComponent variant="fancy" />
141+
```
142+
130143
## Declaration
131144

132145
- Do not use `displayName` for naming components. Instead, name the component by reference.

0 commit comments

Comments
 (0)