In Vue.js, an active component instance will be unmounted when switching away from it by default. But what if you want to preserve the state when switching components? You can wrap it with the built-in <KeepAlive> component to preserve and cache the state. πͺπ»
<template>
<KeepAlive>
<component :is="activeComponent" />
</KeepAlive>
</template>