react-native-css-cascade
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

react-native-css-cascade

Finally, inheritable styles in React Native

React Native's docs say they don't support CSS-style inheritance because they think strong isolation is better. For a React developer migrating to React Native, this violates the Principle of Least Surprise. React Native's styling system was specifically designed to mimic and behave like CSS, yet in their vainglorious hubris for some reason, React Native's designers decided to break CSS's long-established and understood model of inheritance.

So, swap these components in for React Native ones and get the same styles cascading through your React tree that you would expect in CSS.

NPM JavaScript Style Guide

Install

npm install --save react-native-css-cascade

Usage

import { View } from 'react-native-css-cascade'

export const Card = ({ selected, ...props }) => {
  const textColor = selected ? { color: 'green' } : { color: 'black' }
  // All <Text> nodes anywhere in the sub-tree
  // will inherit a color of green when this card is selected
  <View style={textColor} {...props} />
}

License

MIT © matthew-dean

Readme

Keywords

none

Package Sidebar

Install

npm i react-native-css-cascade

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

32.6 kB

Total Files

18

Last publish

Collaborators

  • matthew-dean