Turn a Vue component into a React component.
npm install @egoist/vue-to-react   
This works for both Vue 2 and Vue 3.
``bash`
yarn add @egoist/vue-to-react
`js
import React from 'react'
import { render } from 'react-dom'
import toReact from '@egoist/vue-to-react'
const VueComponent = {
data() {
return {
count: 0
}
},
render(h) {
return h(
'button',
{
on: {
click: () => this.count++
}
},
[this.count]
)
}
}
const ReactComponent = toReact(VueComponent)
render(
`
By default we pass all props from React to Vue:
`js
const Counter = toReact({
props: ['initialCount'],
render(h) {
return h('button', {}, [this.initialCount])
}
})
const App =
`
However you can customize how the props are passed to Vue with the passProps option:
`jsinitialCount
toReact(VueComponent, {
// Only pass prop`
passProps: props => ({ initialCount: props.initialCount }),
// Or disable props
passProps: false
})
1. Fork it!
2. Create your feature branch: git checkout -b my-new-featuregit commit -am 'Add some feature'
3. Commit your changes: git push origin my-new-feature`
4. Push to the branch:
5. Submit a pull request :D
@egoist/vue-to-react © EGOIST, Released under the MIT License.
Authored and maintained by EGOIST with help from contributors (list).
> github.com/egoist · GitHub @EGOIST · Twitter @\_egoistlily