Skip to content
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

TSX support #276

Open
johannes-z opened this issue Dec 18, 2019 · 1 comment
Open

TSX support #276

johannes-z opened this issue Dec 18, 2019 · 1 comment

Comments

@johannes-z
Copy link

I came across a problem, when compiling with bili and using render functions inside a tsx file.

  1. The first proble mis, that the emitted code for h is React.createElement. I have this in my tsconfig.json:
    "jsx": "preserve",
    "jsxFactory": "h",

I found, that using this is needed for bili.config.ts:

  babel: {
    configFile: false,
    jsx: 'h',
  },
  1. Now that React.createElement is "replaced" by h, it still doesn't work if the initial render function calls other functions, that also return TSX, e.g. like this:
render (h) {
  return (
    <div>Parent: {renderSubContent()}</div>
  )
},
renderSubContent() {
  return (
    <span>Content<span>
  )
}

In this case, renderSubContent throws an error, that h is not defined. If I add const h = this.$createElement manually to the function, there are no errors but also nothing gets rendered at all.

@egoist
Copy link
Owner

egoist commented Jan 20, 2020

Yeah currently it only supports React JSX. We need to add an option to disable the built-in JSX plugin so that you can use Vue's babel plugin instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants