react-future icon indicating copy to clipboard operation
react-future copied to clipboard

Add new properties: `classNames` and `styles`

Open scottmas opened this issue 4 years ago • 0 comments

After having programmed in React Native for two years and having finally returned to the web, I am horrified by all the boilerplate involved in conditionally applying styles. The pattern adopted by the community at large and by React Native is to iterate over an array of styles or classnames, filter out falsey values, and then merge the result. See the classnames package with over 4.5 million downloads for proof that this is a need in the community as well as the success of React Native and React Native Web which follow this pattern.

In order to maintain backwards compatibility, I propose keeping the properties style and className as specced, but then adding two additional properties styles and classNames which have the falsey filtering behavior described above. In the case both style and styles are defined on the component, the resulting objects would simply be merged with style taking precedence (similarly for className and classNames).

scottmas avatar May 06 '20 19:05 scottmas