Currently I have these routes:
{ path: '/:username', component: Profile, children: [
{ path: '', component: Map , name: 'Profile'},
{ path: 'locations', component: Locations, name: 'Locations'},
{ path: 'map', component: Map, name: 'Map'}
]},
I need a markers: []
array which gets populated on from my database on mounted()
execution. This array will be used in both Map
and Locations
components.
What is the best way of doing this. I can:
- Have property
markers: []
andmounted()
lifecycle hook in the local state of each component and just execute an axios call on each component. This means 2 axios calls. - Have property
markers: []
andmounted()
lifecycle hook in the local state of the parent of those 2 components and then Props down the data to each component. This means 1 axios call and then I just pass down the data
However, in the second case, I don't know if I would I be able to pass down data in Props since I'm not sure if the components in the nested routes are actually children of the parent element.