Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

rn-fast-classname

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rn-fast-classname

a fast helper to use conditional styles using css in js

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

rn-fast-classname

a fast helper to use conditional styles using css in js

hot to use

To install just run yarn add rn-fast-classname or npm install -s rn-fast-classname.

then:

import getClass from 'rn-fast-className'

const styles = {
  container: {
    backgroundColor: 'red'
  },
  containerFull: {
    flex: 1
  },
};

//...then in the render
render() {
  const containerStyles = getClass(styles, {
    container: true,
    containerFull: this.props.full
  });

  return (
    <Container style={containerStyles}>                  {this.props.children}
    </Container>
  )
}

why rn-fast-classname

rn-fast-classname uses fast-memoize to memoize the return of the getClass function, so if your component need to rerender for any reasons but the styles didn't changed, getClass just will get the result from the cache.

Keywords

classname

FAQs

Package last updated on 27 Sep 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