2
0
mirror of https://github.com/tenrok/vue-meta.git synced 2026-06-16 16:10:33 +03:00

refactor: remove beforeMount hook

This shouldnt be necessary anymore because we force initialization once on mounted/nextTick. Using beforeMount is also inherently less optimal because you are unlikely to benefit from walking the component tree as beforeMount is called before all child components are loaded. So using beforeMount resulted probably that for every component which uses metaInfo a refresh was called on load.

A possible caveat that may exists due to removing beforeMount in favor of a single refresh is that it takes longer for your metaInfo to be updated if you have a lot of components on your page, not sure if this will be a problem in real world scenarios because if this is a problem you should probably be using ssr anyway. Also the v1 docs state that using beforeMount also results in a single update (although in practice it could be more then one)
This commit is contained in:
pimlie
2019-03-09 09:12:58 +01:00
committed by Alexander Lichter
parent f490a48b99
commit 18fd23d3c0
+1 -1
View File
@@ -5,7 +5,7 @@ import { ensuredPush } from './ensure'
export default function createMixin(Vue, options) {
// for which Vue lifecycle hooks should the metaInfo be refreshed
const updateOnLifecycleHook = ['activated', 'deactivated', 'beforeMount']
const updateOnLifecycleHook = ['activated', 'deactivated']
// watch for client side component updates
return {