-
Notifications
You must be signed in to change notification settings - Fork 344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to use JSX directly in setup()
#64
Comments
Could you open an issue there instead please? You probably don't need to use that plugin |
In order to be compatible with the old code, I may have to use this plugin. 😅 Can we import Now only need: import { createComponent } from 'vue-function-api';
// No longer need to manually import `createElement as h`
// import { createComponent, createElement as h } from 'vue-function-api';
export default createComponent({
setup(initialProps) {
// babel plugin will auto-inject h
// const h = this.$createElement;
return (props) => <div>{props.msg}</div>;
},
}); Is there any good solution? |
I would say that the fix is skipping the plugin at https://github.com/vuejs/jsx/blob/dev/packages/babel-sugar-inject-h/src/index.js#L60-L62 if we are in a We cannot add that hack as the lib must stay in sync with the RFC. |
import {
createComponent,
createElement
} from 'vue-function-api'
export default createComponent({
setup: props => {
const h = createElement
return () => {
return (
<div>card</div>
)
}
} |
Hum... I also considered this, but this plugin should eventually solve this problem. If the plugin imports |
@PatrykWalach As long as JSX is used in the function, |
@PatrykWalach Thank you! I didn't see it clearly before. 😂 |
The
createElement
function has been added to the v2.2.0 release, which is great! 🎉But the
babel-sugar-inject-h
plugin attempts to automatically injecth
fromthis.$createElement
, but there is nothis
insetup()
, so JSX cannot be used directly.The text was updated successfully, but these errors were encountered: