-
Notifications
You must be signed in to change notification settings - Fork 240
Error calling React from Vue ("h is not a function") #31
Comments
Ok, I figured it out and now it works. In The fix is to replace that with |
replace `transform-react-jsx` with `babel-plugin-transform-react-jsx` to avoid `h is not a function`
Hey @Enigma10 have you tryed using overrides ? they worked like a charm for me. module.exports = api => ({
presets: ["@babel/env"],
overrides: [
{
test: ["./src"],
presets: [["@vue/app"]]
}
]
}); |
Spend a lot of time to solve this problem. "@vue/app" in current version included vue jsx support, that conflicted with react jsx. module.exports = {
presets: [
["@babel/preset-env"],
["@babel/preset-react"],
],
plugins: [
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-class-properties", { "loose": true }],
["@babel/plugin-syntax-jsx"],
["@babel/plugin-transform-react-jsx"],
["@babel/plugin-syntax-dynamic-import"],
["@babel/plugin-transform-runtime"],
],
} |
@akxcv, is it possible to use vue jsx and react jsx together? |
In theory, yes, if during build time you can use Babel with different transforms for Vue and React files. |
@mpan-wework solution works great for me, thank you. There is only minor tweak - I prefer not to comment out entire preset
|
I'm having issues calling a React component from a freshly generated Vue project and must be doing something wrong.
So, starting with
vue --version
at 2.9.3 (the latest released version) and accepting the defaults in the vue-cli script.vue init webpack myapp cd myapp yarn add vuera react react-dom
Now, I modified the generated
/src/main.js
entrypoint to import and use the VuePlugin from vuera:Modified the generated
App.vue
to import and attempt to use the React component:Finally added the simple React component
/components/ReactComponent.js
:Webpack compiles everything fine, but when requesting
http://localhost:8080
my React component is not rendered under the "Hello World" Vue component. Instead I get 4 errors in the console starting with "Uncaught TypeError: h is not a function".I also tried using the
ReactWrapper
but had the same result.I'm at the latest vuera 0.2.1, vue 2.5.13, react & react-dom 16.2.0, webpack 3.11.0.
This library looks to be awesome once it's working, thanks for any help!
The text was updated successfully, but these errors were encountered: