You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.
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).
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
andclassName
as specced, but then adding two additional propertiesstyles
andclassNames
which have the falsey filtering behavior described above. In the case bothstyle
andstyles
are defined on the component, the resulting objects would simply be merged withstyle
taking precedence (similarly forclassName
andclassNames
).The text was updated successfully, but these errors were encountered: