B
B
BonBon Slick2019-12-09 10:31:25
Vue.js
BonBon Slick, 2019-12-09 10:31:25

Component mounted multiple times?

There is a component, a page with a blog post, on this page, recommended posts in the sidebar and under the post at the bottom of the page.
I just noticed that the component is loaded 2 times and sends a request for recommendations 2 times.
Why is the component reused and not from the cache?
How to prevent it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aetae, 2019-12-12
@BonBonSlick

Because these are 2 different component instances. The component is cached, not its state.
Out of the box, alas, there is no solution for the singleton component. If such a need arises, you will have to manually take care of ensuring the general state and the absence of unnecessary requests.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question