Transform JSX className property to a style property that gets calculated at runtime in React Native. The plugin is used to match style objects containing parsed CSS media queries and CSS viewport units with React Native.
Installations
npm install babel-plugin-react-native-classname-to-dynamic-style
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
8.15.0
NPM Version
6.4.1
Score
36.2
Supply Chain
51.2
Quality
66
Maintenance
50
Vulnerability
94.1
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
kristerkari
Download Statistics
Total Downloads
30,776
Last Day
5
Last Week
50
Last Month
376
Last Year
5,437
GitHub Statistics
13 Stars
61 Commits
7 Forks
3 Watching
8 Branches
1 Contributors
Bundle Size
3.37 kB
Minified
1.13 kB
Minified + Gzipped
Package Meta Information
Latest Version
0.22.0
Package Id
babel-plugin-react-native-classname-to-dynamic-style@0.22.0
Unpacked Size
15.05 kB
Size
3.98 kB
File Count
4
NPM Version
6.4.1
Node Version
8.15.0
Total Downloads
Cumulative downloads
Total Downloads
30,776
Last day
25%
5
Compared to previous day
Last week
-26.5%
50
Compared to previous week
Last month
33.3%
376
Compared to previous month
Last year
-48.2%
5,437
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
babel-plugin-react-native-classname-to-dynamic-style
Transform JSX className
property to a style
property that gets calculated at runtime in React Native. The plugin is used to match style objects containing parsed CSS media queries and CSS viewport units with React Native.
Usage
Step 1: Install
1yarn add --dev babel-plugin-react-native-classname-to-dynamic-style
or
1npm install --save-dev babel-plugin-react-native-classname-to-dynamic-style
Step 2: Configure .babelrc
{
"presets": [
"react-native"
],
"plugins": [
"react-native-classname-to-dynamic-style"
]
}
Syntax
Single class
Example:
1<Text className={styles.myClass} />
↓ ↓ ↓ ↓ ↓ ↓
1var _reactNativeDynamicStyleProcessor = require("react-native-dynamic-style-processor"); 2 3<Text style={_reactNativeDynamicStyleProcessor.process(styles).myClass} />;
...or with className
and style
:
1<Text className={styles.myClass} style={{ color: "blue" }} />
↓ ↓ ↓ ↓ ↓ ↓
1var _reactNativeDynamicStyleProcessor = require("react-native-dynamic-style-processor"); 2 3<Text 4 style={[ 5 _reactNativeDynamicStyleProcessor.process(styles).myClass, 6 { color: "blue" } 7 ]} 8/>;
Multiple classes
Using [styles.class1, styles.class2].join(" ")
syntax
Example:
1<Text className={[styles.class1, styles.class2].join(" ")} />
↓ ↓ ↓ ↓ ↓ ↓
1var _reactNativeDynamicStyleProcessor = require("react-native-dynamic-style-processor"); 2 3<Text 4 style={[ 5 _reactNativeDynamicStyleProcessor.process(styles).class1, 6 _reactNativeDynamicStyleProcessor.process(styles).class2 7 ]} 8/>;
...or with className
and style
:
1<Text 2 className={[styles.class1, styles.class2].join(" ")} 3 style={{ color: "blue" }} 4/>
↓ ↓ ↓ ↓ ↓ ↓
1var _reactNativeDynamicStyleProcessor = require("react-native-dynamic-style-processor"); 2 3<Text 4 style={[ 5 _reactNativeDynamicStyleProcessor.process(styles).class1, 6 _reactNativeDynamicStyleProcessor.process(styles).class2, 7 { color: "blue" } 8 ]} 9/>;
Using template literal syntax
Example:
1<Text className={`${styles.class1} ${styles.class2}`} />
↓ ↓ ↓ ↓ ↓ ↓
1var _reactNativeDynamicStyleProcessor = require("react-native-dynamic-style-processor"); 2 3<Text 4 style={[ 5 _reactNativeDynamicStyleProcessor.process(styles).class1, 6 _reactNativeDynamicStyleProcessor.process(styles).class2 7 ]} 8/>;
...or with className
and style
:
1<Text 2 className={`${styles.class1} ${styles.class2}`} 3 style={{ color: "blue" }} 4/>
↓ ↓ ↓ ↓ ↓ ↓
1var _reactNativeDynamicStyleProcessor = require("react-native-dynamic-style-processor"); 2 3<Text 4 style={[ 5 _reactNativeDynamicStyleProcessor.process(styles).class1, 6 _reactNativeDynamicStyleProcessor.process(styles).class2, 7 { color: "blue" } 8 ]} 9/>;
Using ternary operator
Example:
1<Text className={isTrue ? styles.class1 : styles.class2} />
↓ ↓ ↓ ↓ ↓ ↓
1var _reactNativeDynamicStyleProcessor = require("react-native-dynamic-style-processor"); 2 3<Text 4 style={ 5 isTrue 6 ? _reactNativeDynamicStyleProcessor.process(styles).class1 7 : _reactNativeDynamicStyleProcessor.process(styles).class2 8 } 9/>;
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 0/5 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 27 are checked with a SAST tool
Reason
60 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-cwfw-4gq5-mrqx
- Warn: Project is vulnerable to: GHSA-g95f-p29q-9xw4
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-3gx7-xhv7-5mx3
- Warn: Project is vulnerable to: GHSA-8r6j-v8pm-fqw3
- Warn: Project is vulnerable to: MAL-2023-462
- Warn: Project is vulnerable to: GHSA-2pr6-76vf-7546
- Warn: Project is vulnerable to: GHSA-8j8c-7jfh-h6hx
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp
- Warn: Project is vulnerable to: GHSA-4xcv-9jjx-gfj3
- Warn: Project is vulnerable to: GHSA-7wpw-2hjm-89gp
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-4g88-fppr-53pp
- Warn: Project is vulnerable to: GHSA-4jqc-8m5r-9rpr
- Warn: Project is vulnerable to: GHSA-4rq4-32rv-6wp6
- Warn: Project is vulnerable to: GHSA-64g7-mvw6-v9qj
- Warn: Project is vulnerable to: GHSA-3f95-r44v-8mrg
- Warn: Project is vulnerable to: GHSA-28xr-mwxg-3qc8
- Warn: Project is vulnerable to: GHSA-9p95-fxvg-qgq2
- Warn: Project is vulnerable to: GHSA-9w5j-4mwv-2wj8
- Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9
- Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw
- Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc
- Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh
- Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp
- Warn: Project is vulnerable to: GHSA-6chw-6frg-f759
- Warn: Project is vulnerable to: GHSA-rq8g-5pc5-wrhr
- Warn: Project is vulnerable to: GHSA-hr2v-3952-633q
- Warn: Project is vulnerable to: GHSA-h6ch-v84p-w6p9
- Warn: Project is vulnerable to: GHSA-xf7w-r453-m56c
- Warn: Project is vulnerable to: GHSA-44pw-h2cw-w3vq
- Warn: Project is vulnerable to: GHSA-jp4x-w63m-7wgm
- Warn: Project is vulnerable to: GHSA-c429-5p7v-vgjp
- Warn: Project is vulnerable to: GHSA-6394-6h9h-cfjg
- Warn: Project is vulnerable to: GHSA-6g33-f262-xjp4
- Warn: Project is vulnerable to: GHSA-2m39-62fm-q8r3
- Warn: Project is vulnerable to: GHSA-mf6x-7mm4-x2g7
- Warn: Project is vulnerable to: GHSA-j44m-qm6p-hp7m
Score
1.7
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More