Imagine we have already mounted an App
in main.js:
createApp(App).mount('#app');
Now, I want to create a function that is called like this:
createModal({
render: () => <SomeComponent />,
});
Typically, we would implement the function above by calling createApp(h(render))
and then mounting its instance wherever needed.
However, the issue arises when the modal instance does not inherit anything from the root App.
For example, if we use provide('root', 'here')
in the root App and then call inject('root')
in another App, we will not get the expected result of here
.
Instead, the result will be undefined
since the two Apps do not share the same context.
So, how can we rectify this issue and ensure everything functions correctly?