Vue2 Mixins in Repeated Components

86 Views Asked by At

I have a Vue component that displays information for a log entry. On my page, I have a for loop that instantiates this component for each log entry. I could have anywhere from 0 - potentially 100+ logs.

<log-entry v-for="(log, index) in logs) :key=index :log="log" />

I have a mixin that contains some methods that can be used all over my application such as a method that looks up a user by their ID.

$_myAppMixin_lookupUserById(id, users) {
   // return user with matching id
}

My question is, what kind of performance hit will my app take if I use the mixin in the log-entry component?

I'm thinking that if my log-entry component is instantiated 50 times on a page, my app is loading the mixin 50 times. I'm wondering though, is Vue able to reconcile all the duplicate code?

0

There are 0 best solutions below