> ## Documentation Index
> Fetch the complete documentation index at: https://loadwise.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# vue-v-if-with-v-for

> A v-if on the same element as v-for filters by the loop variable, re-checking every item each render instead of using a computed list.

## What it flags

An element in a `.vue` template that has both `v-for` and a `v-if` reading the loop variable, such as `<li v-for="order in orders" v-if="order.paid">`. Vue 2 evaluates the `v-if` for every item of the whole list on every render; Vue 3 evaluates it before the loop, where the loop variable does not exist. See the [Vue style guide](https://vuejs.org/style-guide/rules-essential.html#avoid-v-if-with-v-for).

A `v-if` that reads only component state, such as `v-if="showOrders"`, is not reported, nor is `v-show` or a `v-if` on an inner element or a wrapping `<template>`. Names that only appear in a destructuring default (`fallback` in `({ id = fallback }) in rows`) or as the parameter of a callback inside the `v-if` (`others.some(item => item.active)`) do not count as reads of the loop variable, and neither does an object key such as `item` in `accept({ item: true })`.

## How to review or fix

Loop over a `computed` list that is already filtered. To hide the whole list, move the `v-if` to a wrapping element or `<template>`.

## Configuration

Set the rule to `"off"` in `loadwise.config.json` to drop its findings:

```json theme={null}
{
  "rules": { "vue-v-if-with-v-for": "off" }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.