|
|
3 vuotta sitten | |
|---|---|---|
| .. | ||
| test | 3 vuotta sitten | |
| .babelrc | 3 vuotta sitten | |
| .eslintrc | 3 vuotta sitten | |
| .npmignore | 3 vuotta sitten | |
| .travis.yml | 3 vuotta sitten | |
| LICENSE | 3 vuotta sitten | |
| README.md | 3 vuotta sitten | |
| index.js | 3 vuotta sitten | |
| package.json | 3 vuotta sitten | |
| yarn.lock | 3 vuotta sitten | |
This babel plugin adds some syntactic sugar to JSX.
npm i babel-plugin-jsx-vue-functional -D
or
yarn add babel-plugin-jsx-vue-functional -D
Then add jsx-vue-functional to your .babelrc file under plugins
example .babelrc:
{
"presets": ["es2015"],
"plugins": ["jsx-vue-functional", "transform-vue-jsx"]
}
Example:
const A = () => <h1>Hello World</h1>
export const B = ({ props, listeners }) => <div onClick={listeners.click}>{props.msg}<A /></div>
will be transpiled into:
const A = {
functional: true,
render: (h) => <h1>Hello World</h1>
}
export const B = {
functional: true,
render: (h, { props, listeners }) => <div onClick={listeners.click}>{props.msg}<A /></div>
}
This plugin will transform all named arrow functions that contain JSX and starting with version 2.0.0 so this code will not work:
const A = () => <h1>Hello World</h1>
export const B = ({ props, listeners }) => <div onClick={listeners.click}>{props.msg}{A()}</div>