Is it bad practice to modify state directly from multiple components? #1341
Unanswered
ChrisGV04
asked this question in
Help and Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi! I'm currently developing an app that uses Pinia stores extensively and as I was implementing a CRUD feature I had a situation that I don't know if it has any cons or performance issues.
Context
Lets say that I have a product store with something like this:
Now, I have a product editor page that looks something like this:
Each block on that page is one of 3 separate components:
createdAt
/updatedAt
and the "Save" button.Since they are all separate components that use the same product, they share the state by connecting to the product store. Now, my question is...
Question
Is it okay to directly edit the state from multiple components using
v-model
so that when I click on the "Save" button, the store already has all of the changes in it? Something like this:My question mostly comes from the performance standpoint, since I'm not sure if changing the state directly from multiple separate components has bad performance, can make my page slower or is it just a bad practice with pinia.
I would really appreciate your ideas and suggestions!
Beta Was this translation helpful? Give feedback.
All reactions