$ npm install babel-plugin-transform-jsx-condition
Support of transform jsx condition directive.
In
// input code
<View x-if={condition}>First</View>
<View x-elseif={another}>Second</View>
<View x-else>Third</View>
Out
{
createCondition([
[
() => condition,
() => <View}>First</View>
],
[
() => another,
() => <View}>Second</View>
],
[
() => true,
() => <View}>Third</View>
],
])
}
$ npm install babel-plugin-transform-jsx-condition
.babelrc
(Recommended).babelrc
{
"plugins": ["transform-jsx-condition"]
}
$ babel --plugins transform-jsx-condition script.js
require("babel-core").transform("code", {
plugins: ["transform-jsx-condition"]
});
© 2010 - cnpmjs.org x YWFE | Home | YWFE