--- stage: none group: unassigned info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments --- # Migration to Vue 3 The migration from Vue 2 to 3 is tracked in epic [&6252](https://gitlab.com/groups/gitlab-org/-/epics/6252). To ease migration to Vue 3.x, we have added [eslint rules](https://gitlab.com/gitlab-org/frontend/eslint-plugin/-/merge_requests/50) that prevent us from using the following deprecated features in the codebase. ## Vue filters **Why?** Filters [are removed](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0015-remove-filters.md) from the Vue 3 API completely. **What to use instead** Component's computed properties / methods or external helpers. ## Event hub **Why?** `$on`, `$once`, and `$off` methods [are removed](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0020-events-api-change.md) from the Vue instance, so in Vue 3 it can't be used to create an event hub. **When to use** If you are in a Vue app that doesn't use any event hub, try to avoid adding a new one unless absolutely necessary. For example, if you need a child component to react to its parent's event, it's preferred to pass a prop down. Then, use the watch property on that prop in the child component to create the desired side effect. If you need cross-component communication (between different Vue apps), then perhaps introducing a hub is the right decision. **What to use instead** We have created a factory that you can use to instantiate a new [mitt](https://github.com/developit/mitt)-like event hub. This makes it easier to migrate existing event hubs to the new recommended approach, or to create new ones. ```javascript import createEventHub from '~/helpers/event_hub_factory'; export default createEventHub(); ``` Event hubs created with the factory expose the same methods as Vue 2 event hubs (`$on`, `$once`, `$off` and `$emit`), making them backward compatible with our previous approach. ## \