Is it okay to mutate a props
if it's a Pinia state?
#1556
-
Hi 👋 I am passing a Pinia state object from parent component to child component via Everything works until I lint the code and get flagged with this finding:
I think this warning is intended for components not using Pinia as state management, but I wanted to make sure I'm not breaking any patterns either. I've read documentation that says the child component should emit the event back up for the parent component to handle. But should that not apply since I am using Pinia? I'm wondering, given my use of Pinia, is it okay to just ignore this linter finding? Thank you for your time 🙏 My code is below:
The parent component:
The child component:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
no, you still shouldn't modify a prop because the idea behind a prop is that you don't know where it comes from. You either emit events and use v-model on the prop or use the store within the component and couple it to the store. Note the last version prevents you from using the component without the store and it's less flexible. |
Beta Was this translation helpful? Give feedback.
no, you still shouldn't modify a prop because the idea behind a prop is that you don't know where it comes from. You either emit events and use v-model on the prop or use the store within the component and couple it to the store. Note the last version prevents you from using the component without the store and it's less flexible.