Setting up a useState
const product = useState('product', () => null);
Watching for the locale to change on the client side:
if(locale != 'en' || 'en-US') {
// data is a response from useFetch
let translatedProduct = data.value.product.locales.find(i => i.locale == newLocale);
product.value = translatedProduct;
} else {
product.value = data.value.product
});```
When accessing the useState in a child component, I can use `{{product.name}}` in the <template> just fine. However if I need to run a find/filter on an array within the product in my `<script /> ` section `console.log(product.links)` returns undefined.
I also tried `console.log(product.value.links)` what am I missing or not understanding about accessing useState and using it in the script section.
UPDATE: I have added a reproduction link https://stackblitz.com/edit/github-4op7ia?file=components%2Fproduct.vue
I added a timeout to simulate the locale value updating on the client-side. It seems I am not understanding how to properly update useState value