[Vuejs]-Passing data to sub-components in Vue JS. Best practices?

1đź‘Ť

As far as my experience is concerned, 1-st way is better. Parent component acts as “smart” and you have access to it’s life cycle hooks in order to trigger your api-requests, reset timers, e.t.c… I would also suggest to use vuex, as it allows you to make clean interface of communication between your parent component and “outer world”, utilizing actions and getters.

With that being said, your “dumb” child component communicates with it’s parent through props and emits interface. And because it is “dumb” – it’s easier to test it or utilize something like “storybook”.

we have to send the correct object structure to the child component to avoid any error

I guess, at the end of the day, you’ll need correct object structure anyway, right? It could not be just random…

Leave a comment