L
L
low molecular macro2021-04-07 11:29:47
Vue.js
low molecular macro, 2021-04-07 11:29:47

Do I need to store all data in a store if I'm already using Vuex?

If I use Vuex, do I need to store all data in state? At this stage, in state I only store information about the current user - to make it easier to use in several components.

But here I have a page where I display a list of products that is loaded from the database. This list will only appear on one specific page. Whether to write it down in state? If yes, then why?
And if this list is already used not on one, but on several pages, then in order to avoid duplication, it seems like it makes sense to store the entire list in state ... But the records in the database can change, and I need to load the list on a new one every time - then store the list in store doesn't make sense if it's mutable?

Please explain about the example I gave and in general about what data is recommended (and what is not recommended) to be stored in the store.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin B., 2021-04-07
@Kostik_1993

The convenience of Vuex is not only that it is a single data repository between components, but also a great place to organize business logic to manage them. If it's a multiple, once you write an action, you can map it to your components without duplicating code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question