1π
- Passing whole data will make the your
Task
component independent from store. - Passing only
id
s of tasks will make yourTask
component dependent on store for tasks data.
Since Task
is representing a single card, I think making it dependent on the store will increase the calls to the store since n
number of tasks will call store for data.
It is better to get the data from store once and then enumerating the data using v-for
directive and passing whole task
object to your Task
component.
0π
So you can pass it however you like. Keep in mind, if youβre using Vuex, you donβt need to pass anything as a prop since you have a central source of truth. Instead, you can call straight from the state or use a getter.
Inside your child component, you can refer to the store with $store
in the template and this.$store
in the script.
For example:
const myTasks = this.$store.state.tasks
(if tasks
is an array or collection of some sort)
const myTask = this.$store.state.tasks[0]
Then you have myTask.id
, myTask.label
, etc.
If you need a more specific example, please post more code and let me know.