You may have an infinite update loop in a component render function vue js

Viewed 26

Im using method to hide or show " In stock " label this's my HTML :

<span class="stock" v-if="inStock(variance)">{{$t('in_stock')}}</span>

and the method

inStock(variance){
        variance.quantity.forEach((q)=>{
            if(q.location_id == this.defaultWarehouseID){
                this.defaultQuantity = q.quantity
            }
        }
        )
        if(this.defaultQuantity > 0) return true
        else return false
    

and I'm getting this error :- You may have an infinite update loop in a component render function

NOTE :- I know this error because I'm using reactive data while rendering , but I don't know how to use block scoped variable with the arrow function inside forEach

0 Answers
Related