
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
babel-plugin-react-native-stylename-to-style
Advanced tools
Transform JSX styleName property to style property in react-native.
Transform JSX styleName
property to style
property in react-native. The styleName
attribute and syntax are based on babel-plugin-react-css-modules.
yarn add --dev babel-plugin-react-native-stylename-to-style
or
npm install --save-dev babel-plugin-react-native-stylename-to-style
.babelrc
You must give one or more file extensions inside an array in the plugin options.
{
"presets": [
"react-native"
],
"plugins": [
["react-native-stylename-to-style", {
"extensions": ["css"]
}]
]
}
Anonymous reference can be used when there is only one stylesheet import.
import "./Button.css";
<View styleName="wrapper">
<Text>Foo</Text>
</View>;
↓ ↓ ↓ ↓ ↓ ↓
import Button from "./Button.css";
<View style={Button.wrapper}>
<Text>Foo</Text>
</View>;
import "./Button.css";
<View styleName="wrapper red-background">
<Text>Foo</Text>
</View>;
↓ ↓ ↓ ↓ ↓ ↓
import Button from "./Button.css";
<View style={[Button.wrapper, Button["red-background"]]}>
<Text>Foo</Text>
</View>;
import "./Button.css";
const name = "wrapper";
<View styleName={name}>
<Text>Foo</Text>
</View>;
↓ ↓ ↓ ↓ ↓ ↓
import Button from "./Button.css";
const name = "wrapper";
<View
style={(name || "")
.split(" ")
.filter(Boolean)
.map(function(name) {
Button[name];
})}
>
<Text>Foo</Text>
</View>;
import "./Button.css";
const condition = true;
const name = "wrapper";
<View styleName={condition ? name : "bar"}>
<Text>Foo</Text>
</View>;
↓ ↓ ↓ ↓ ↓ ↓
import Button from "./Button.css";
const condition = true;
const name = "wrapper";
<View
style={((condition ? name : "bar") || "")
.split(" ")
.filter(Boolean)
.map(function(name) {
Button[name];
})}
>
<Text>Foo</Text>
</View>;
styleName
and style
:import "./Button.css";
<View styleName="wrapper" style={{ height: 10 }}>
<Text>Foo</Text>
</View>;
↓ ↓ ↓ ↓ ↓ ↓
import Button from "./Button.css";
<View style={[Button.wrapper, { height: 10 }]}>
<Text>Foo</Text>
</View>;
Named reference is used to refer to a specific stylesheet import.
import foo from "./Button.css";
<View styleName="foo.wrapper">
<Text>Foo</Text>
</View>;
↓ ↓ ↓ ↓ ↓ ↓
import foo from "./Button.css";
<View style={foo.wrapper}>
<Text>Foo</Text>
</View>;
import foo from "./Button.css";
import bar from "./Grid.css";
<View styleName="foo.wrapper bar.column">
<Text>Foo</Text>
</View>;
↓ ↓ ↓ ↓ ↓ ↓
import foo from "./Button.css";
import bar from "./Grid.css";
<View style={[foo.wrapper, bar.column]}>
<Text>Foo</Text>
</View>;
FAQs
Transform JSX styleName property to style property in react-native.
The npm package babel-plugin-react-native-stylename-to-style receives a total of 1,141 weekly downloads. As such, babel-plugin-react-native-stylename-to-style popularity was classified as popular.
We found that babel-plugin-react-native-stylename-to-style demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.