From a599bca47492035fa5b9fdd9d1ba23743877a44f Mon Sep 17 00:00:00 2001 From: Joe Lencioni Date: Mon, 19 Sep 2016 11:42:12 -0700 Subject: [PATCH] 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. --- react/README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/react/README.md b/react/README.md index d672e56b..9d4d9da3 100644 --- a/react/README.md +++ b/react/README.md @@ -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 + + + // good + + ``` + ## Declaration - Do not use `displayName` for naming components. Instead, name the component by reference.