Comments (2)
Just in case you didn't know, you can rename them while destructuring:
const { for: htmlFor, class: classNames } = {
for() {},
class() {},
};
from babel-plugin-jsx.
Hello,
sure I am familiar with object deconstructing syntax. But my main issue is, that I have library, which is already outputting JSX template (using className
instead of class
) and wanted to write Vue wrapper for it. If I rename className
to just class
there, it would break in React instead. My current JSX template implementation in that library looks like this (simplified):
class Library {
constructor(options) {
// ...
}
// ...
get attributes() {
// ...
return {
// ...
};
}
// ...
get template() {
const { attributes } = this;
return <div ...attributes>...</div>;
}
}
Note that this is not in Vue (or React) component, but it is only getter from my library, that should be used in Vue/React component as template. Basic usage in Vue/React would be as instance (which is reactive) and each mutation of its state would change my JSX template output that would be directly mapped into component.
Sure I can copy whole template getter from my library to Vue component and use it like this:
// ...
render() {
const { attributes } = this;
if(attributes.className) {
attributes.class = attributes.className;
delete attributes.className;
}
return <div ...attributes>...</div>;
}
// ...
But then I would have to manage separate template just for Vue, which I wanted to avoid in first place. At this point, it would be more straightforward to use standard Vue template syntax instead of JSX.
It would be nice, if this plugin could transform className
into class
(and htmlFor
into for
) attribute at compilation time, otherwise I would suggest to rename it to something else (e.g.: .vjsx
), because it is not (fully) compatible with JSX syntax, that React defined first.
Thanks.
from babel-plugin-jsx.
Related Issues (20)
- [Question] In the future and Object slot typing be supported by this plugin HOT 2
- [Question] How to pass function slots ? HOT 1
- [BUG] empty string transform to true
- Action Required: Fix Renovate Configuration
- [BUG] empty string transform to true HOT 2
- [Question] How to pass any attribute to the component HOT 2
- [BUG] Excluding a file will prevent it from still getting parsed as JSX causing errors
- Can this plugin be used in a browser? HOT 1
- vModel 修饰符不能动态 HOT 2
- [BUG] {} 渲染异常 HOT 1
- [BUG] tsup bundle problem HOT 2
- [BUG] Typescript typings HOT 1
- [BUG] "resolveDirective" is imported from external module "vue" but never used
- [Question] Help配置列表 HOT 1
- [Question] directives:v-model or vModel?v-show or vShow? HOT 1
- [BUG] Report bug HOT 1
- [Question] how to make vue jsx ast return to jsx HOT 1
- [Question] How to set a Symbolic Link in README.md HOT 2
- The inline style setting failed HOT 1
- When JSX is used, v-slots cause child component does unnecessary rendering during parent component re-rendering HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from babel-plugin-jsx.