single-spa / single-spa-vue

a single-spa plugin for vue.js applications
MIT License
182 stars 42 forks source link

Fixed the update lifecycle method to support Vue 3. #76

Closed lsphillips closed 3 years ago

lsphillips commented 3 years ago

Problem

The update lifecycle method doesn't work in Vue 3.

Explanation

With Vue 2 you create an application like so:

const app = new Vue({
    // ...
});

With this instance you can mount it and update its props like so:

app.mount('#element');

app['prop'] = 'value';

In Vue 3, this has changed. You still create an application, like so:

const app = createApp({
    // ...
});

However, when you mount an application you will get a reference to the root component, which is what you use to update reactive data after the fact:

const root = app.mount('#element');

root['prop'] = 'value';

Question: I'm not really sure how to create an automation test for this as the test suite uses Vue 2.x.x. When this is a Vue 3.x.x problem.

joeldenning commented 3 years ago

Released in https://github.com/single-spa/single-spa-vue/releases/tag/v2.4.0