Advertisement
crutch12

React + Vue

Jun 5th, 2024 (edited)
707
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react';
  2. import { createApp, defineAsyncComponent } from 'vue'
  3.  
  4. const VueApp = defineAsyncComponent(() => import('vueApp/App'))
  5.  
  6. const ReactApp = () => {
  7.   const vueApp = React.useRef()
  8.  
  9.   React.useEffect(() => {
  10.     const app = createApp(VueApp, { /* props */ })
  11.  
  12.     app.mount(vueApp.current)
  13.  
  14.     return () => {
  15.       app.unmount()
  16.     }
  17.   }, [])
  18.  
  19.   return <div>
  20.     <div ref={vueApp} />
  21.   </div>
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement