# Conditional Rendering

Components can optionally implement a <mark style="color:red;">`render_if`</mark> method which allows components to render only If the result of the <mark style="color:red;">`render_if()`</mark> method is <mark style="color:red;">`False`</mark>. Using our CarListComponent from our previous example, lets implement this.&#x20;

```python
CardListComponent.py
class CardListComponent:
    with_collection_parameter = "cars"
    
    def __init__(self, cars=cars, cars_counter:int):
        self.cars = cars
        self.counter = cars_counter
        
    def render_if(self):
        return with_collection_parameter == "trucks":
            
```

Now if we try to render our component it will not render.&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bayside.gitbook.io/mv-components/essentials/conditional-rendering.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
