🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

react-native-style-prop-type

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

react-native-style-prop-type

A React PropType for React Native styles

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

React Native Style Prop Type

code style: prettier

js-standard-style

Description

Validate React Native styles by ensuring the style keys are valid React Native style properties.

  • Required prop type validation is supported, similar to the built-in prop types.
    • ReactNativeStylePropType.isRequired
  • Style array validation is also supported.
    • style={[styles.textStyle1, styles.textStyle2]}

Usage

import { StyleSheet, Text, View } from 'react-native';
import ReactNativeStylePropType from 'react-native-style-prop-type';

const Component = ({style, textStyle}) => (
  <View style={style}>
    <Text style={textStyle}>My Component</Text>
  </View>
);

Component.propTypes = {
  style: ReactNativeStylePropType.isRequired,
  textStyle: ReactNativeStylePropType
};

const Page = () => (
  <Component style={styles.style} textStyle={[styles.textStyle1, styles.textStyle2]} />
);

const styles = StyleSheet.create({
  style: { ... },
  textStyle1: { ... },
  textStyle2: { ... }
})

Installation

npm i react-native-style-prop-type -S

Special Thanks

Thanks to Frankie Bagnardi for creating the original react-style-proptype package which this package builds on top of.

Keywords

React

FAQs

Package last updated on 22 Jun 2023

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