am trying to integrate https://react-table.js.org/#/story/readme in vue.js app using https://github.com/akxcv/vuera.
My main.js:
import Vue from 'vue'
import { VuePlugin } from 'vuera'
import App from './App'
import router from './router'
Vue.config.productionTip = false
Vue.use(VuePlugin)
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
template: '<App/>',
components: { App },
})
My HelloWorld.vue:
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<ReactTable :data="data" :columns="columns" />
</div>
</template>
<script>
import ReactTable from 'react-table'
import 'react-table/react-table.css'
export default {
name: 'HelloWorld',
components: { ReactTable },
data () {
return {
msg: 'Welcome to Your Vue.js App',
columns: [{ Header: 'Name', accessor: 'name' }],
data: [ {name: 'tom'}]
}
}
}
</script>
Upon running this code I get two errors in console:
[Vue warn]: Error in mounted hook: "TypeError: children is not a function"
found in
---> <ReactWrapper>
<ReactTable>
<HelloWorld> at src/components/HelloWorld.vue
<App> at src/App.vue
<Root>
and:
vue.esm.js?efeb:1717 TypeError: children is not a function
at ReactTable.render (index.js?5f89:822)
at eval (ReactCompositeComponent.js?063f:793)
at measureLifeCyclePerf (ReactCompositeComponent.js?063f:73)
at ReactCompositeComponentWrapper._renderValidatedComponentWithoutOwnerOrContext (ReactCompositeComponent.js?063f:792)
at ReactCompositeComponentWrapper._renderValidatedComponent (ReactCompositeComponent.js?063f:819)
at ReactCompositeComponentWrapper.performInitialMount (ReactCompositeComponent.js?063f:359)
at ReactCompositeComponentWrapper.mountComponent (ReactCompositeComponent.js?063f:255)
at Object.mountComponent (ReactReconciler.js?c56c:43)
at ReactCompositeComponentWrapper.performInitialMount (ReactCompositeComponent.js?063f:368)
at ReactCompositeComponentWrapper.mountComponent (ReactCompositeComponent.js?063f:255)
Is it something wrong I'm coding or vuera plugin just doesn't handle ReactTable component integration correctly?
Many thanks for any ideas!
Vue in React - Preferred usageThe preferred way to use Vue inside of a React app is to use a Babel plugin. Now, just use your Vue components like you would use your React components!
Which one is more popular React or Vue? As per Google Trends and StackOverflow, React has acquired considerable popularity compared to Vue. However, considering GitHub, Vue overtakes React with its stars. This means both the languages are quite popular and are here to stay for long.
Vue also uses virtual DOM, and the structural principles are similar to React. This is why the speed and performance quality of Vue vs React performance don't differ much. However, Vue is faster when it comes to component creation and updates.
Vue also uses the virtual DOM, but compared to React, Vue has better performance and stability. According to this data, Vue and React's performance difference is subtle since it is only a few milliseconds. This proves that Vue and React are very similar in terms of performance.
So I recreated the project and it worked fine for me, below are set of dependencies I used. I think your case it might be just version mismatch issue
"dependencies": {
"react": "^16.3.1",
"react-dom": "^16.3.1",
"react-table": "^6.8.0",
"vue": "^2.5.2",
"vue-router": "^3.0.1",
"vuera": "^0.2.1"
}
Please make sure you try with above version. The output is
The project is available on below link if you want to just clone and test
https://github.com/tarunlalwani/react-vue-integration
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With