Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

Add new properties: classNames and styles #57

Open
scottmas opened this issue May 6, 2020 · 0 comments
Open

Add new properties: classNames and styles #57

scottmas opened this issue May 6, 2020 · 0 comments

Comments

@scottmas
Copy link

scottmas commented May 6, 2020

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).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant