Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@technicalbros/react-native-styles

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@technicalbros/react-native-styles

JSS like styles for react native

  • 1.0.6
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
2
Weekly downloads
 
Created
Source

react-native-styles

This library provides a nice way to handle styles and overrides in React Native components, inspired by JSS for web.

Usage with Typescript

MyButton.tsx

import * as React from "react";
import {withStyles} from "@technicalbros/react-native-styles";
import {TouchableOpacity, Text} from "react-native";

//@ts-ignore
@withStyles({
    root: {
        backgroundColor: "red",
        width: "100%",
        padding: 8
    },
    text: {
        color: "white"
    }
})
export class MyButton extends React.Component{
    
    props: {
        styles?: {
            root?:any,
            text?:any
        },
        children: any
    }
    
    render(){
        
        const {styles, children} = this.props;
        
        return <TouchableOpacity style={styles.root}>
            <Text style={styles.text}>{children}</Text>
        </TouchableOpacity>
    }
}

Here @withStyles decorator creates a high order component, which injects a styles prop in the original component.

MyButton usage

<MyButton 
    styles={{
        backgroundColor: "blue"
    }}
>
    Click Me
</MyButton>

In above code, only backgroundColor will be overridden from "red" to "blue", while other style remains the same as defaults.

FAQs

Package last updated on 05 Mar 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc