Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. import React from 'react'
  2. import Vue from 'vue'
  3.  
  4. // v2r(VueComponent) => ReactComponent
  5. export const v2r = Component => {
  6. return () => {
  7. const el = React.useRef(null)
  8.  
  9. React.useEffect(() => {
  10. const app = new Vue({
  11. el: el.current,
  12. render: h => h(Component)
  13. })
  14.  
  15. return () => app.$destroy()
  16. })
  17.  
  18. return React.createElement('div', { ref: el })
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement