Render Vuejs application as a Microfront end in a existing react application

Hi,
I 'm trying to render Vue js application dynamically on click of a navigation link in an existing React application.On click of the link I try to download the js and execute the js by calling the renderVueApp.
This function renderVueApp contains the vue logic to createApp and mount in a div container.
On click of a navigation link I create a script to download js as follows:

const script = document.createElement(‘script’);
script.src = http://localhost:8080/js/app.js;
script.onload = this.renderVueJsApplication;
document.head.appendChild(script);

renderVueJsApplication = () => {
window.renderVueApp(containerId)
}

Vue Js Application
main.js
import { createApp } from ‘vue’
import App from ‘./App.vue’

window.renderVueApp = (containerId) => createApp(App).mount(containerId));

Will this logic work as I get error renderVueApp() is a not function.If not how can i expose createApp() logic outside. If this question is not clear, please let me know. I’ll try to add more details and make it clear.Thanks in advance.