Vue composition api composable functions lifecycle

Viewed 380

I have two composable functions in setup of my component:

setup(props, context) {

const {product, getProduct} = useProduct();

const {label, getLabel} = useLabel(product);


onBeforeMount(async() => {
await getProduct(root.$route.params.productId);
}

Here is my Problem. I import the methods/ refs of the composable functions useProduct & useLabel. I retrieve the value of the specific product in "onMounted" but pass the ref inside the setup which is called before. So product in useLabel is undefined. How can I pass it right when "product" has a value and use label inside of setup? Or is there an other way to achieve this?

0 Answers
Related