New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

classnames-react-native

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

classnames-react-native

This library resolve styles merging in react-native

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
2
-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

ClassNames for React Native

This library resolve styles merging in react-native

Like package classNames for regular React

Install

Step one:

npm i classnames-react-native

Step two:

Enjoy!

API

classnames([styleObject][, [styleObject, conditions]])

Examples

Example #1

import classNames from 'classnames-react-native'

const A = { padding: 10 }
const B = { backgroudColor: '#fff' }
const C = { margin: 10 }

classnames(A, [B, true], [C, false ])
// classNames(styleObject, [styleObject, conditions], [styleObject, conditions])


/*  classNames returns this styles:  */
{
  padding: 10, // from object A
  backgroudColor: "#fff", // from object B (conditions is positive)
  // object C is ignored (because conditions is negative)
}

Example #2

import classNames from 'classnames-react-native'
import StyleGuide from '../../style/xxx'
import style from './style'

class Example extends Component {
  render() {
    const { wide = true, ghost = false } = this.props
    const style = classNames(
      StyleGuide.spacing.large,
      style.root,
      // or units style
      [style.wide, wide],
      // or union style
      [
        style.transparent, ghost,
        style.fill, true,
      ],
    )
    
    /*
     * classnames returns object, witch includes styles:
     * - spacing
     * - root
     * - wide
     * - fill
     */

    return (
        <View style={style}>
            ...
        </View>
    )
  }
}

FAQs

Package last updated on 23 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts